From owner-freebsd-questions@freebsd.org Sat Apr 18 12:07:06 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AAD522C736A for ; Sat, 18 Apr 2020 12:07:06 +0000 (UTC) (envelope-from pawel@jasiak.xyz) Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 494BXT2YwNz470D for ; Sat, 18 Apr 2020 12:07:04 +0000 (UTC) (envelope-from pawel@jasiak.xyz) Received: by mail-lj1-x244.google.com with SMTP id 67so881236ljj.4 for ; Sat, 18 Apr 2020 05:07:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jasiak-xyz.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=5x243pLNRRLB5sf7QAnJbQnJFnW7HXWh0ID4J8BdIFQ=; b=ZICej6p8r9LMKYPtl4lGlGSVxYwuqhFyZepgRnwBowhWnuFbjOK5CnWb230Z4futZC pht9/plUPe68NQvmeVei4bUPGiP9+bf4P/yzRU31ZnvAGc2i27bebHE6d8lk1RXPFOat Rd4Fdc3cPTPuGadfNaJ1IBj6JzHGatBowisT1ugHmtyUWtrpxL/vUIYcR3HLMEhHiwp3 21A/bFS7jYANv9jByhlcaf1t/bhMm38+sHF5NTGboK1kwaFRk2w2LlVe1q2JEQ5x7amz Wyr9LwuE21olNePFNg1DKuE6Hpu1+eGnScgLX5ej5bovjDr2Bm9iMdQj9kvMj9u049xJ KgKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5x243pLNRRLB5sf7QAnJbQnJFnW7HXWh0ID4J8BdIFQ=; b=BmDIlEqe5d4QmEmA8L8HS6tJTYL0MnaA/1XYcquGVlA0DP1Zd5ZpBTNmreeLg7qKZe GvZK2B1ag1hhtZY/0wRw0EiLqz2FFRvNdNMUTvEJhPRYmtQ52vyiMC0NYXPMGYTzA8ZM 1NC77mERjT4mPV//x129Z32IaG36JlM53AU01OgjiyeYamOUzxetNARqIdamAn3D+8Py 5Mv4aJN1pgFPOCjc0Oi/AsedH+dSQKHBevldVmwsYiBazeDBjq3dAeaRrKT5tr3WKRmm 21xUctzoo8lCw+dyaxcprxaxmH6AAWvOvNmk+iBikqMl3f7ECHvGwKQsAqavb7f2IVqW C4Gw== X-Gm-Message-State: AGi0PuZGteB4LOqDrGRhCKtHaCHOjWU6ZrRZmj+ZWjp520+C0s0unN34 nrwmCcYtz41d0MbqkefS8G8i5RF2XiA= X-Google-Smtp-Source: APiQypIzTm5UxU7GH1hvIxSVUxSjU8uAUNxsu+WrmHw1QBFSUpod/A2BZfWOR3qohz5DCw7j3foz6g== X-Received: by 2002:a2e:7006:: with SMTP id l6mr4599884ljc.269.1587211623340; Sat, 18 Apr 2020 05:07:03 -0700 (PDT) Received: from gmail.com (wireless-nat-78.ip4.greenlan.pl. [185.56.211.78]) by smtp.gmail.com with ESMTPSA id a22sm18493615ljm.28.2020.04.18.05.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2020 05:07:02 -0700 (PDT) Date: Sat, 18 Apr 2020 14:07:00 +0200 From: =?utf-8?B?UGF3ZcWC?= Jasiak To: Polytropon Cc: freebsd-questions@freebsd.org Subject: Re: Arguments format Message-ID: <20200418120700.GA47913@gmail.com> References: <20200417160556.GA44862@gmail.com> <20200417184725.b49109b7.freebsd@edvax.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="k+w/mQv8wyuph6w0" Content-Disposition: inline In-Reply-To: <20200417184725.b49109b7.freebsd@edvax.de> X-Rspamd-Queue-Id: 494BXT2YwNz470D X-Spamd-Bar: ++ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=jasiak-xyz.20150623.gappssmtp.com header.s=20150623 header.b=ZICej6p8; dmarc=none; spf=pass (mx1.freebsd.org: domain of pawel@jasiak.xyz designates 2a00:1450:4864:20::244 as permitted sender) smtp.mailfrom=pawel@jasiak.xyz X-Spamd-Result: default: False [2.08 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(0.00)[jasiak-xyz.20150623.gappssmtp.com:s=20150623]; NEURAL_HAM_MEDIUM(-0.38)[-0.379,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(0.00)[+ip6:2a00:1450:4000::/36]; RECEIVED_SPAMHAUS_XBL(5.00)[78.211.56.185.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.4]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; DMARC_NA(0.00)[jasiak.xyz]; BAD_REP_POLICIES(0.10)[]; NEURAL_HAM_LONG(-0.43)[-0.433,0]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[jasiak-xyz.20150623.gappssmtp.com:+]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[4.4.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.5.4.1.0.0.a.2.list.dnswl.org : 127.0.5.0]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; IP_SCORE(-0.01)[ip: (2.78), ipnet: 2a00:1450::/32(-2.34), asn: 15169(-0.43), country: US(-0.05)]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_TLS_ALL(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[78.211.56.185.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Apr 2020 12:07:06 -0000 --k+w/mQv8wyuph6w0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Thanks for your response! On 17/04/20, Polytropon wrote: > On Fri, 17 Apr 2020 18:05:56 +0200, Pawe=C5=82 Jasiak wrote: > > 1. In sys/mips/mips/autoconf.c we have functions > >=20 > > static void configure_first(dummy) > > static void configure(dummy) > > static void configure_final(dummy) > >=20 > > and we are not using argument. We are having those functions also in > > ricv, arm, arm64, powerpc and x86 and in non of them we are using dummy, > > so maybe we can just remove it? Or if it is necessary why we don't mark > > it as __unused like in other functions? >=20 > I haven't checked any further, but I could imagine that > is has to do with the requirement of those functions > being able - at least in their declaration - to accept > a parameter; the type void * is a "somewhat universal" > type. Note that the functions are being mentioned in > macros, such as >=20 > SYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, N= ULL); >=20 > in /usr/src/sys/powerpc/powerpc/autoconf.c which might > be the reason why there has to be a dummy parameter... >=20 > Okay, further investigation. ;-) >=20 > According to "man 9 SYSINIT", the definition is >=20 > SYSINIT(uniquifier, enum sysinit_sub_id subsystem, > enum sysinit_elem_order order, sysinit_cfunc_t func, > const void *ident); >=20 > and the type sysinit_cfunc_t is defined as >=20 > typedef void (*sysinit_cfunc_t)(const void *); >=20 > in /usr/src/sys/sys/kernel.h, so this is the reaon why > the configure_first(), configure(), and configure_final() > functions have to be "compatible". Thanks, I didn't really pay attention to SYSINIT but still don't=20 understand why we don't mark the arguments as __unused. > > 2. Above functions have strange definition for arguments. > >=20 > > static void > > configure(dummy) > > void *dummy; > > { > > ... > > } > >=20 > > Why we are not using > >=20 > > static void > > configure(void *dummy) > > { > > ... > > } > >=20 > > like in other places? >=20 > That is not a strange format, it's an older dialect of C, > usually called "K&R C", where the definition of a function > typically is: >=20 > return-type function-name(arg1, arg2, arg3, ...) > type arg1; > type arg2; > type arg3; > ... > { > function-body > } >=20 > A convention also is to put the function's return type on > an individual line, so the function's name always starts > at column 1. >=20 > See "man 9 style" for details. >=20 > Still, this style is not being followed consistently: >=20 > % grep "^configure_first" `find /usr/src/sys -name autoconf.c` > /usr/src/sys/x86/x86/autoconf.c:configure_first(void *dummy) > /usr/src/sys/arm64/arm64/autoconf.c:configure_first(void *dummy) > /usr/src/sys/arm/arm/autoconf.c:configure_first(void *dummy) > /usr/src/sys/riscv/riscv/autoconf.c:configure_first(void *dummy) > /usr/src/sys/sparc64/sparc64/autoconf.c:configure_first(void *dummy) > /usr/src/sys/powerpc/powerpc/autoconf.c:configure_first(void *dummy) > /usr/src/sys/mips/mips/autoconf.c:configure_first(dummy) >=20 > Some use "K&R C" style, others use "ANSI C" style. Thanks, I know both styles and I was worried about mixing them. > > 3. In sys/mips/mips/octeon_cop2.c we are having > >=20 > > struct octeon_cop2_state * > > octeon_cop2_alloc_ctx() > > { > > ... > > } > > but it's declaration in sys/mips/include/octeon_cop2.h is > >=20 > > struct octeon_cop2_state* octeon_cop2_alloc_ctx(void); > >=20 > > Question is if we should change octeon_cop2_alloc_ctx() into > > octeon_cop2_alloc_ctx(void)? >=20 > There is a difference between () and (void) which _might_ be > intended; however, prototype and declaration should in fact > have the same signature. If the argument is (), the function > will accept any parameters, including none ("any parameters > list"); if it's (void), the function will refuse to accept > any parameters ("emtpy parameter list"), which is explicit > for "it doesn't use any parameters". I know the difference again ;)=20 % grep -nr "octeon_cop2_alloc_ctx" sys/mips/mips/vm_machdep.c:164: td2->td_md.md_cop2 =3D octeon_c= op2_alloc_ctx(); sys/mips/mips/vm_machdep.c:169: td2->td_md.md_ucop2 =3D octeon_= cop2_alloc_ctx(); sys/mips/mips/octeon_cop2.c:53:octeon_cop2_alloc_ctx() sys/mips/mips/trap.c:942: td->td_md.md_cop2 =3D octeon_co= p2_alloc_ctx(); sys/mips/mips/trap.c:995: td->td_md.md_ucop2 =3D = octeon_cop2_alloc_ctx(); sys/mips/include/octeon_cop2.h:208:struct octeon_cop2_state* octeon_cop2_al= loc_ctx(void); I believe that all uses of the octeon_cop2_alloc_ctx function so I still don't understand why we have different signatures. Thanks! --=20 Pawe=C5=82 Jasiak --k+w/mQv8wyuph6w0 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEENIqkLxDcCMlLMdi0FzfmQudzVTgFAl6a7WAACgkQFzfmQudz VTg2phAAj1VuhTNQzDbyvrMl1IYzuw0fAEjoQRXFuZ2mlumnvBEbr9AqS4PJZ8wf +DLwxw0mpjOYkjs3/3UaJYGVSBW53jY2XlrgKMVUm6r/dEQySmxbRSzJjV1nk6bB d30WUK01yNn519Yj//qK19OHC6KxnzBtnwQx2VX9h5bU7rVr5CROhMppuvgAc029 rJ4THXwdghBRgTLvw/vZ0dxVNOBW5MKQybFMEsIHmHpNlkrFMdq0MFPonE7ukYcT T2oP079USjKtaqHlMBJioY3Pm+V0Hf3PT6ndovvYBJnz7G3robJv3UwrY0/0sJ+G l/sVT4wtZThcybE3ZslfOPAqW4Hyqk90D42m4OTYZNc7uqAU9DlpJCUPBVPnqcF4 A2o+JJxkY6qDrFxa1b1/08FfXS115N848N4GlqReKqg+tjHyvoQKzgidtswJeXJT oyfssBu627731nVCqccxvNpLe1/tWtIPBMf2O+7z16uHjTkiA/QXPfEktBEGjaoB rbckNkeTC39JwzEWMUvPX3/jDhP7RZ5uNwI2cv43qYeaPpbP3VyU9/VSEV/ZFlXI KVGZw0C/5aGyF+XxOCDgQVz8pwRcklzEJ6SPGds0i12LT0aqSDKDoKKoFhJcRYSW DAtZUvAbKGMikpeE2qTReO01pi8/uVM7g8kuApM1US24PSuiVZY= =LgTT -----END PGP SIGNATURE----- --k+w/mQv8wyuph6w0--