Remove getopt_long() from headers

We removed this API a long time ago and it was breaking the GNU make
open source build.
This commit is contained in:
Justine Tunney 2023-06-17 16:03:16 -07:00
parent b881c0ec9e
commit 12452976bd
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
8 changed files with 12 additions and 23 deletions

View file

@ -20,6 +20,7 @@
#include "libc/calls/syscall-nt.internal.h" #include "libc/calls/syscall-nt.internal.h"
#include "libc/calls/syscall-sysv.internal.h" #include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h" #include "libc/dce.h"
#include "libc/intrin/strace.internal.h"
/** /**
* Sets current directory based on file descriptor. * Sets current directory based on file descriptor.
@ -30,9 +31,12 @@
* @asyncsignalsafe * @asyncsignalsafe
*/ */
int fchdir(int dirfd) { int fchdir(int dirfd) {
int rc;
if (!IsWindows()) { if (!IsWindows()) {
return sys_fchdir(dirfd); rc = sys_fchdir(dirfd);
} else { } else {
return sys_fchdir_nt(dirfd); rc = sys_fchdir_nt(dirfd);
} }
STRACE("fchdir(%d) → %d% m", dirfd, rc);
return rc;
} }

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_GROUPS_INTERNAL_H_ #ifndef COSMOPOLITAN_LIBC_CALLS_GROUPS_INTERNAL_H_
#define COSMOPOLITAN_LIBC_CALLS_GROUPS_INTERNAL_H_ #define COSMOPOLITAN_LIBC_CALLS_GROUPS_INTERNAL_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0) #if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_ COSMOPOLITAN_C_START_

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/calls/calls.h"
#include "libc/calls/syscall-sysv.internal.h" #include "libc/calls/syscall-sysv.internal.h"
#include "libc/calls/termios.h" #include "libc/calls/termios.h"
#include "libc/dce.h" #include "libc/dce.h"
@ -41,6 +42,8 @@ int tcgetpgrp(int fd) {
rc = sys_ioctl(fd, TIOCGPGRP_linux, &pgrp); rc = sys_ioctl(fd, TIOCGPGRP_linux, &pgrp);
} else if (IsBsd()) { } else if (IsBsd()) {
rc = sys_ioctl(fd, TIOCGPGRP_bsd, &pgrp); rc = sys_ioctl(fd, TIOCGPGRP_bsd, &pgrp);
} else if (IsWindows()) {
rc = getpid();
} else { } else {
rc = enosys(); rc = enosys();
} }

View file

@ -28,7 +28,7 @@ char *strpbrk(const char *s, const char *accept) {
if (!accept[1]) { if (!accept[1]) {
return strchr(s, accept[0]); return strchr(s, accept[0]);
} else { } else {
memset(lut, 0, sizeof(lut)); bzero(lut, sizeof(lut));
while (*accept) { while (*accept) {
lut[*accept++ & 255] = true; lut[*accept++ & 255] = true;
} }

View file

@ -1,10 +1,5 @@
#ifndef COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_ #ifndef COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_
#define COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_ #define COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_
#define no_argument 0
#define required_argument 1
#define optional_argument 2
#if !(__ASSEMBLER__ + __LINKER__ + 0) #if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_ COSMOPOLITAN_C_START_
@ -14,17 +9,6 @@ extern int optind, opterr, optopt, optreset;
int getopt(int, char *const[], const char *) paramsnonnull(); int getopt(int, char *const[], const char *) paramsnonnull();
int getsubopt(char **, char *const *, char **) paramsnonnull(); int getsubopt(char **, char *const *, char **) paramsnonnull();
struct option {
const char *name;
int has_arg;
int *flag;
int val;
};
int getopt_long(int, char *const *, const char *, const struct option *, int *);
int getopt_long_only(int, char *const *, const char *, const struct option *,
int *);
COSMOPOLITAN_C_END_ COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_ */ #endif /* COSMOPOLITAN_THIRD_PARTY_GETOPT_GETOPT_H_ */

View file

@ -15,6 +15,7 @@ LICENSE
LOCAL CHANGES LOCAL CHANGES
- Introduce $(uniq token...) native function
- .INTERNET variable to allow internet access - .INTERNET variable to allow internet access
- .PLEDGE variable which restricts system calls - .PLEDGE variable which restricts system calls
- .UNVEIL variable which controls Landlock LSM - .UNVEIL variable which controls Landlock LSM

View file

@ -16,11 +16,9 @@ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "third_party/getopt/getopt.h"
/* clang-format off */ /* clang-format off */
#ifndef _GETOPT_H #ifndef _GETOPT_H
#if 0 && !defined(_GETOPT_H)
#define _GETOPT_H 1 #define _GETOPT_H 1
#ifdef __cplusplus #ifdef __cplusplus
@ -136,6 +134,5 @@ extern int _getopt_internal (int argc, char *const *argv,
const char *shortopts, const char *shortopts,
const struct option *longopts, int *longind, const struct option *longopts, int *longind,
int long_only); int long_only);
#endif
#endif /* getopt.h */ #endif /* getopt.h */

View file

@ -69,6 +69,7 @@
"__builtin_ctzll" "__builtin_ctzll"
"__builtin_expect" "__builtin_expect"
"__builtin_memcpy" "__builtin_memcpy"
"__builtin_memset"
"__builtin_expect_with_probability" "__builtin_expect_with_probability"
"__builtin_extract_return_addr" "__builtin_extract_return_addr"
"__builtin_isnan" "__builtin_isnan"