mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
This takes another step towards cleaning up the build system. We now do not even pretend to be theoretically compatible with pre-1989 K&R C compilers or with C++ compilers. In practice, this had already been broken for many years due to bit rot. Commit46593a89already removed the license handling enormity that depended on proto, so now we can cleanly remove it altogether. But we do need to leave some backwards compatibility stubs to keep the build system compatible with older AST code; it should remain possible to build older ksh versions with the current build system (the bin/ and src/cmd/INIT/ directories) for testing purposes. So as of now there is no more __MANGLE__d rubbish in your generated header files. This is only about a quarter of a century overdue... This commit also includes a huge amount of code cleanup to remove thousands of unused K&R C fallbacks and other cruft, particularly in libast. This code base should now be a little easier to understand for people who are familiar with a modern(ish) C standard. ratz is now also removed; this was a standalone and simplified 2005 version of gunzip. As of6137b99a, none of our code uses it, even theoretically. And the real g(un)zip is now everywhere. src/cmd/INIT/proto.c, src/cmd/INIT/ratz.c: - Removed. COPYRIGHT: - Remove zlib license; this only applied to ratz. bin/package, src/cmd/INIT/package.sh: - Related cleanups. - Unset LC_ALL before invoking a new shell, respecting the user's locale again and avoiding multibyte character corruption on the command line. src/cmd/INIT/proto.sh: - Add stub for backwards compatibility with Mamfiles that depend on proto. It does nothing but pass input without modification and is now installed as the new arch/*/bin/proto by src/cmd/INIT/Mamfile. src/cmd/INIT/iffe.sh: - Ignore the proto-related -e (--package) and -p (--prototyped) options; keep parsing them for backwards compatibility. - Trim the macros passed to every test to their standard C versions, removing K&R C and C++ versions. These are now considered to be for backwards compatibility only. src/cmd/INIT/iffe.tst: - Remove proto(1) mangling code. By the way, iffe can be regression-tested as follows: $ bin/package use # set up environment in a child shell $ regress src/cmd/INIT/iffe.tst $ exit # leave package environment src/cmd/INIT/make.probe, src/cmd/INIT/probe.win32: - Remove code to handle C++. src/lib/libast/features/common: - As in iffe.sh above, trim macros designed for compatibility with C++ and ancient C compilers to their standard C versions and comment that they are for backwards compatibility with AST code. This is needed to keep all the old ast and ksh code compiling. src/cmd/ksh93/sh/init.c, src/cmd/ksh93/sh/name.c: - Clarify libshell ABI compatibility function versions of macros. A "proto workaround" comment in the original code mislead me into thinking this had something to do with the removed proto(1), but it's unrelated. Call the workaround macro BYPASS_MACRO instead. src/cmd/ksh93/include/defs.h: - sh_sigcheck() macro: allow &sh as an argument: parenthesise shp. src/cmd/ksh93/sh/nvtype.c: - Remove unused nv_mkstruct() function. (re:d0a5cab1) **/features/*: - Remove obsolete iffe 'set prototyped' option. **/Mamfile: - Remove all references to the ast/prototyped.h header. - Remove all use of the proto command. Simply copy instead. *** 850-ish source files: *** - Remove all '#pragma prototyped' directives. - Remove all C++ compat code conditional upon defined(__cplusplus). - Remove all use of the _ARG_ macro, which on standard C expands to its argument: #define _ARG_(x) x (on K&R C, it expanded to nothing) - Remove all use of _BEGIN_EXTERNS_ and _END_EXTERNS_ macros (empty on standard C; this was for C++ compatibility) - Reduce all #if __STD_C (standard code) #else (K&R code) #endif blocks to the standard code only, without use of the macro. - Same for _STD_ macro which seems to have had the same function. - Change all instances of 'Void_t' to standard 'void'.
279 lines
8 KiB
Text
279 lines
8 KiB
Text
iff AST_SYS
|
|
ref -D_def_map_ast
|
|
|
|
print #if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
|
|
print #define _NO_LARGEFILE64_SOURCE 1
|
|
print #endif
|
|
print #if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
|
|
print #if !defined(_LARGEFILE64_SOURCE)
|
|
print #define _LARGEFILE64_SOURCE 1
|
|
print #endif
|
|
print #if !defined(_LARGEFILE_SOURCE)
|
|
print #define _LARGEFILE_SOURCE 1
|
|
print #endif
|
|
print #if !defined(_LARGE_FILE_API)
|
|
print #define _LARGE_FILE_API 1
|
|
print #endif
|
|
print #else
|
|
print #undef _LARGEFILE64_SOURCE
|
|
print #undef _LARGEFILE_SOURCE
|
|
print #undef _LARGE_FILE_API
|
|
print #undef _typ_ino64_t
|
|
print #undef _typ_off64_t
|
|
print #undef _typ_struct_dirent64
|
|
print #undef _lib_creat64
|
|
print #undef _lib_fstat64
|
|
print #undef _lib_fstatvfs64
|
|
print #undef _lib_ftruncate64
|
|
print #undef _lib_lseek64
|
|
print #undef _lib_lstat64
|
|
print #undef _lib_mmap64
|
|
print #undef _lib_open64
|
|
print #undef _lib_readdir64
|
|
print #undef _lib_stat64
|
|
print #undef _lib_statvfs64
|
|
print #undef _lib_truncate64
|
|
print #endif
|
|
print #if !_lib_readdir64
|
|
print #undef _typ_ino64_t
|
|
print #endif
|
|
|
|
print #if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
|
|
print #define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
|
|
print #endif
|
|
|
|
header stdlib.h
|
|
header stddef.h
|
|
header sys/types.h
|
|
header stdint.h
|
|
header inttypes.h
|
|
header string.h
|
|
header unistd.h
|
|
header limits.h
|
|
header fcntl.h
|
|
header locale.h
|
|
|
|
typ dev_t,nlink_t fail{
|
|
echo "#ifndef $m"
|
|
echo "#define $m 1"
|
|
echo "typedef short $v;"
|
|
echo "#endif"
|
|
}end
|
|
typ gid_t,mode_t,uid_t fail{
|
|
echo "#ifndef $m"
|
|
echo "#define $m 1"
|
|
echo "typedef unsigned short $v;"
|
|
echo "#endif"
|
|
}end
|
|
typ wchar_t stdio.h wchar.h fail{
|
|
echo "#ifndef $m"
|
|
echo "#define $m 1"
|
|
echo "typedef unsigned short $v;"
|
|
echo "#endif"
|
|
}end
|
|
typ pid_t,ssize_t fail{
|
|
echo "#ifndef $m"
|
|
echo "#define $m 1"
|
|
echo "typedef int $v;"
|
|
echo "#endif"
|
|
}end
|
|
typ wint_t stdio.h wchar.h fail{
|
|
echo "#ifndef $m"
|
|
echo "#define $m 1"
|
|
echo "typedef int $v;"
|
|
echo "#endif"
|
|
}end
|
|
typ socklen_t sys/socket.h fail{
|
|
echo "#ifndef $m"
|
|
echo "#define $m 1"
|
|
echo "typedef int $v;"
|
|
echo "#endif"
|
|
}end
|
|
typ size_t fail{
|
|
echo "#ifndef $m"
|
|
echo "#define $m 1"
|
|
echo "typedef unsigned int $v;"
|
|
echo "#endif"
|
|
}end
|
|
typ clock_t,ino_t,off_t,ptrdiff_t fail{
|
|
echo "#ifndef $m"
|
|
echo "#define $m 1"
|
|
echo "typedef long $v;"
|
|
echo "#endif"
|
|
}end
|
|
typ time_t fail{
|
|
echo "#ifndef $m"
|
|
echo "#define $m 1"
|
|
echo "typedef unsigned long $v;"
|
|
echo "#endif"
|
|
}end
|
|
typ div_t fail{
|
|
echo "#ifndef $m"
|
|
echo "#define $m 1"
|
|
echo "typedef struct { int quot; int rem; } $v;"
|
|
echo "#endif"
|
|
}end
|
|
typ ldiv_t fail{
|
|
echo "#ifndef $m"
|
|
echo "#define $m 1"
|
|
echo "typedef struct { long quot; long rem; } $v;"
|
|
echo "#endif"
|
|
}end
|
|
tst typ_signed_size_t output{
|
|
#include <sys/types.h>
|
|
int
|
|
main()
|
|
{
|
|
unsigned long u = ~0;
|
|
size_t s = ~0;
|
|
if (s >= 0)
|
|
return 1;
|
|
printf("#if !defined(_typ_signed_size_t)\n/* ensure unsigned size_t */\ntypedef unsigned %s _ast_size_t;\n#undef\tsize_t\n#define size_t\t_ast_size_t\n#endif\n", u == (unsigned long)s ? "long" : "int");
|
|
return 0;
|
|
}
|
|
}end
|
|
|
|
define offsetof (type,member) __builtin_offsetof(type,member)
|
|
define EXIT_FAILURE 1
|
|
define EXIT_SUCCESS 0
|
|
define MB_CUR_MAX 1
|
|
define RAND_MAX 32767
|
|
|
|
define STDIN_FILENO 0
|
|
define STDOUT_FILENO 1
|
|
define STDERR_FILENO 2
|
|
|
|
define NULL 0
|
|
|
|
define SEEK_SET 0
|
|
define SEEK_CUR 1
|
|
define SEEK_END 2
|
|
|
|
define F_OK 0
|
|
define X_OK 1
|
|
define W_OK 2
|
|
define R_OK 4
|
|
|
|
print #if _BLD_ast && defined(__EXPORT__)
|
|
print #define extern __EXPORT__
|
|
print #endif
|
|
|
|
extern _exit void (int)
|
|
extern abort void (void)
|
|
extern abs int (int)
|
|
extern access int (const char*, int)
|
|
extern alarm unsigned (unsigned)
|
|
extern atexit int (void(*)(void))
|
|
extern atof double (const char*)
|
|
extern atoi int (const char*)
|
|
extern atol long (const char*)
|
|
extern bsearch void* (const void*, const void*, size_t, size_t, int(*)(const void*, const void*))
|
|
extern calloc void* (size_t, size_t)
|
|
extern cfree void (void*)
|
|
extern chdir int (const char*)
|
|
extern chown int (const char*, uid_t, gid_t)
|
|
extern close int (int)
|
|
extern confstr size_t (int, char*, size_t)
|
|
extern div div_t (int, int)
|
|
extern dup int (int)
|
|
extern dup2 int (int, int)
|
|
extern eaccess int (const char*, int)
|
|
extern execl int (const char*, const char*, ...)
|
|
extern execle int (const char*, const char*, ...)
|
|
extern execlp int (const char*, const char*, ...)
|
|
extern execv int (const char*, char* const[])
|
|
extern execve int (const char*, char* const[], char* const[])
|
|
extern execve int (const char*, char* const[], char* const[])
|
|
extern execvp int (const char*, char* const[])
|
|
extern execvpe int (const char*, char* const[], char* const[])
|
|
extern exit void (int)
|
|
extern fork pid_t (void)
|
|
extern fpathconf long (int, int)
|
|
extern free void (void*)
|
|
extern fsync int (int)
|
|
extern ftruncate int (int, off_t)
|
|
extern getcwd char* (char*, size_t)
|
|
extern getegid gid_t (void)
|
|
extern getenv char* (const char*)
|
|
extern geteuid uid_t (void)
|
|
extern getgid gid_t (void)
|
|
extern getgroups int (int, gid_t[])
|
|
extern getlogin char* (void)
|
|
extern getpgrp pid_t (void)
|
|
extern getpid pid_t (void)
|
|
extern getppid pid_t (void)
|
|
extern gettxt char* (const char*, const char*)
|
|
extern getuid uid_t (void)
|
|
extern isatty int (int)
|
|
extern labs long (long)
|
|
extern ldiv ldiv_t (long, long)
|
|
extern link int (const char*, const char*)
|
|
extern lseek off_t (int, off_t, int)
|
|
extern malloc void* (size_t)
|
|
extern mblen int (const char*, size_t)
|
|
extern mbstowcs size_t (wchar_t*, const char*, size_t)
|
|
extern mbtowc int (wchar_t*, const char*, size_t)
|
|
extern memalign void* (size_t, size_t)
|
|
extern memccpy void* (void*, const void*, int, size_t)
|
|
extern memchr void* (const void*, int, size_t)
|
|
extern memcmp int (const void*, const void*, size_t)
|
|
extern memcpy void* (void*, const void*, size_t)
|
|
extern memmove void* (void*, const void*, size_t)
|
|
extern memset void* (void*, int, size_t)
|
|
extern pathconf long (const char*, int)
|
|
extern pause int (void)
|
|
extern pipe int (int[])
|
|
extern pvalloc void* (size_t)
|
|
extern qsort void (void*, size_t, size_t, int(*)(const void*, const void*))
|
|
extern rand int (void)
|
|
extern read ssize_t (int, void*, size_t)
|
|
extern realloc void* (void*, size_t)
|
|
extern realpath char* (const char*, char*)
|
|
extern resolvepath char* (const char*, char*, size_t)
|
|
extern rmdir int (const char*)
|
|
extern setgid int (gid_t)
|
|
extern setpgid int (pid_t, pid_t)
|
|
extern setsid pid_t (void)
|
|
extern setuid int (uid_t)
|
|
extern sleep unsigned (unsigned int)
|
|
extern spawnveg pid_t (const char*, char* const[], char* const[], pid_t)
|
|
extern srand void (unsigned int)
|
|
extern strcasecmp int (const char*, const char*)
|
|
extern strcat char* (char*, const char*)
|
|
extern strchr char* (const char*, int)
|
|
extern strcmp int (const char*, const char*)
|
|
extern strcoll int (const char*, const char*)
|
|
extern strcpy char* (char*, const char*)
|
|
extern strcspn size_t (const char*, const char*)
|
|
extern strdup char* (const char*)
|
|
extern strlcat size_t (char*, const char*, size_t)
|
|
extern strlcpy size_t (char*, const char*, size_t)
|
|
extern strlen size_t (const char*)
|
|
extern strncasecmp int (const char*, const char*, size_t)
|
|
extern strncat char* (char*, const char*, size_t)
|
|
extern strncmp int (const char*, const char*, size_t)
|
|
extern strncpy char* (char*, const char*, size_t)
|
|
extern strpbrk char* (const char*, const char*)
|
|
extern strrchr char* (const char*, int)
|
|
extern strspn size_t (const char*, const char*)
|
|
extern strstr char* (const char*, const char*)
|
|
extern strtok char* (char*, const char*)
|
|
extern strxfrm size_t (char*, const char*, size_t)
|
|
extern swab void (const void*, void*, ssize_t)
|
|
extern sysconf long (int)
|
|
extern system int (const char*)
|
|
extern tcgetpgrp pid_t (int)
|
|
extern tcsetpgrp int (int, pid_t)
|
|
extern truncate int (const char*, off_t)
|
|
extern ttyname char* (int)
|
|
extern unlink int (const char*)
|
|
extern valloc void* (size_t)
|
|
extern wcstombs size_t (char*, const wchar_t*, size_t)
|
|
extern wctomb int (char*, wchar_t)
|
|
extern write ssize_t (int, const void*, size_t)
|
|
|
|
print #undef extern
|
|
|
|
# <stdarg.h> is handled by proto so this must be after the last test
|
|
|
|
print #include <stdarg.h>
|