Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116902 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 38824 invoked from network); 20 Jan 2022 13:42:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Jan 2022 13:42:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 97F97180382 for ; Thu, 20 Jan 2022 06:54:11 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 20 Jan 2022 06:54:11 -0800 (PST) Received: by mail-yb1-f173.google.com with SMTP id v186so18596115ybg.1 for ; Thu, 20 Jan 2022 06:54:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AYEngVWJAvObGPDFmn+276x5sa/KteRBOgM275eQTLY=; b=XQOXcl3W4BpMfvkzg6B+fxBxHd8Wk/EP03SnjNw37ueRKo5jU9VzbJ83CmJYAn8PMQ LHmpqBy92O3fHs5TgVE9jWzIbQE2mJSBDlgLsjTJA+2DpeSFIVjGNP8E9c84yWgHB1Yu 3HRl6VTFC1gOK1H7GzFDDzn5bt4iIzYoFnfSU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AYEngVWJAvObGPDFmn+276x5sa/KteRBOgM275eQTLY=; b=3Sjh9sps5620+N4vMunliT0Nu6Qae4Fm/BBM2t4fBq3ME06AlPR3Q8gZnQoW0ptXN1 9AWvTPBSVJwRXepe36fgmrwKW8lygrcY6wyoyB9vX7UZXDmM1nsJB/d7hbPkRcTeKAhw JZhAXF6ChNuO5TKKy2IvkFgLjnIiTiGexNgjomPLbtJm9kaRQUcSomdO3U2cagYB7Fdx 1ZB4/LqpRKYV4QAOI49/WgRNoj0GVaFLXqO4+NOmWjU52AL2TKsmQtHDLGfcQY+kS5Wd ZfKyxkXMPTlnkg3KHW/GXOQWfhb38gebg9oFxBG2BqbOFsu7Ym+zGM/5m82TqqenB0Z5 7RQA== X-Gm-Message-State: AOAM530rGcWpAge7o+yxGk6eCUa+KYP+KZF+HWMNGfsnujGHmv7ygzr0 AcxT2/fSqayVK8S1vq4AjjhLI1bT5KiaETYSOP4HFdG1W2GeQg== X-Google-Smtp-Source: ABdhPJx4d4//wlWezQHEU0d1SxXHYmk0jzoZY9XDvvog4/maEJtMCi4jj9W7Vu6OJ5A75VM4Z0m7Q+X/8VboAYzGVHg= X-Received: by 2002:a25:2244:: with SMTP id i65mr10431182ybi.14.1642690450333; Thu, 20 Jan 2022 06:54:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Reply-To: Levi Morrison Date: Thu, 20 Jan 2022 07:53:58 -0700 Message-ID: To: "Su, Tao" Cc: "internals@lists.php.net" Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [Help] Reason on when to declare and protect ZEND_API function From: internals@lists.php.net ("Levi Morrison via internals") On Thu, Jan 20, 2022 at 1:56 AM Su, Tao wrote: > > Hello internals, > > I am trying to read Zend header files to understand its functional interfaces, > but have got confusion and anybody knows why zend_startup_system_id() and zend_finalize_system_id() > do not have to be protected by BEGIN_EXTERN_C()/END_EXTERN_C() enclosure, > but zend_add_system_entropy() has to. > > Is the following code intentional for any reason? > And also, these two functions do not have ZEND_API attribute. Thanks. > > Zend/zend_system_id.h > BEGIN_EXTERN_C() > /* True global; Write-only during MINIT/startup */ > extern ZEND_API char zend_system_id[32]; > > ZEND_API ZEND_RESULT_CODE zend_add_system_entropy(const char *module_name, const char *hook_name, const void *data, size_t size); > END_EXTERN_C() > > void zend_startup_system_id(void); > void zend_finalize_system_id(void); > > > ======================================= > Tony Su (Su, Tao) > make a 'lazy' programmer diligently with efficiency > I haven't looked at the details of these specific functions recently, but in general functions which are marked ZEND_API are capable of being called from extensions and modules. These same ZEND_API functions need to be in `extern "C"` sections for that to happen if the extension or module is using C++. I would guess that `zend_startup_system_id` and `zend_finalize_system_id` do not need to be used outside of the engine but needed to have a forward declaration for code organization reasons.