From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 17 01:45:52 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 07498B3F for ; Thu, 17 Oct 2013 01:45:52 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-qa0-x233.google.com (mail-qa0-x233.google.com [IPv6:2607:f8b0:400d:c00::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BB8FB28B8 for ; Thu, 17 Oct 2013 01:45:51 +0000 (UTC) Received: by mail-qa0-f51.google.com with SMTP id ii20so1237951qab.3 for ; Wed, 16 Oct 2013 18:45:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=BITJ/Ib0WnAbo6G6ud/BttdZxADg2TLAtMD/2F/zBQE=; b=tOaHxiOFlLmtJJ0ZuHRgc/NRf7r6jOU9H+jyo5Fku7I9PW2/lRT+mLYV055hl8lBAL M2xGEzXyRpQMhFGoa/YsqfzXKCN6Djf3hJ1C8FCXDqMdH3Vz9psLCHeJ5R0gsKLvoCqB TQQFV+dHXUvYAY2WBsANawS4ysiD2n1YiygHA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=BITJ/Ib0WnAbo6G6ud/BttdZxADg2TLAtMD/2F/zBQE=; b=lnWaNvzcQCJ8fOVl6O4LdAIoeTjVgQqUFx+lEL6p6Qfs6KcG9UTwjf41l+98GFpAwi XNlx9U1TgUrOS943IO/BXbEdFbYDvAtDmQdHcoXiTHRuEwRb3bIMWLz1tZRaWgnmwgsv cs4UvWy1z3kGEHVyP3jqydjbSBVQLZrgz1ZJqYsg27pHY8j6xgwg1DgmDFupJzvsXaWc fe8XracZ3zJdlk9z2qNJ1qybBgLrQyhA5ryjBxoGsZsWkoXp1HcfSl9SmUkX/t0tNG3s aPIDWjNwvXbfjeUsdoRBFVrfoXk7rOl824uRV9aeE3U2OcO65NFDsZLAOoa5Ds3t5Qy1 eeTA== X-Gm-Message-State: ALoCoQnej4YzyG+EZE4qUe7LKDvXrMWoM8L/WkC9XsntraTXR2RxagGtobZW6K56K4RO5P8hoabR X-Received: by 10.224.125.138 with SMTP id y10mr8667335qar.40.1381974350751; Wed, 16 Oct 2013 18:45:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.96.63.101 with HTTP; Wed, 16 Oct 2013 18:45:20 -0700 (PDT) In-Reply-To: <525D5A35.4040005@embedded-brains.de> References: <525D5A35.4040005@embedded-brains.de> From: Eitan Adler Date: Wed, 16 Oct 2013 21:45:20 -0400 Message-ID: Subject: Re: Global variables in system programs To: Sebastian Huber Content-Type: text/plain; charset=UTF-8 Cc: FreeBSD Hackers X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Oct 2013 01:45:52 -0000 On Tue, Oct 15, 2013 at 11:07 AM, Sebastian Huber wrote: > These programs use some global variables. In a statically linked context we > have now the following problems This is a pretty awesome idea. I've seen some work like this but it would be great to get FreeBSD into a state where this is easy. Are patches acceptable for the FreeBSD project that alter > system programs such that > o global variables are moved into context structures, Provided that the code remains readable I think these would be fine. > o constant global variables are declared as "const", and > o variables and functions are declared as "static" if possible? There has been a lot of work on this area. Your patch surprises me because I see many changes which were already done. We would absolutely be interested in such patches > Attached is a patch for the ROUTE(8) program to give an example. This patch can not apply for instance patchfile: 960 961 -char metricnames[] = 962 +static const char metricnames[] = 963 "\011weight\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire" 964 "\1mtu"; but actual file: 1557 static const char metricnames[] = 1558 "\011weight\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire" 1559 "\1mtu"; If you can generate patches against HEAD that would be great. I notice you use git: try to generate patches against https://github.com/freebsd/freebsd -- Eitan Adler