Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d86ed29

Browse files
committed
Added table entries for Irix 6.5 names for confstr()/sysconf()/
pathconf() names, from Sjoerd. Added code to verify that these tables are properly ordered, only included and used when CHECK_CONFNAME_TABLES is defined. This is only needed to test the tables, so I haven't enabled this by default.
1 parent 1a5eb04 commit d86ed29

1 file changed

Lines changed: 174 additions & 0 deletions

File tree

Modules/posixmodule.c

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3415,6 +3415,12 @@ conv_confname(arg, valuep, table, tablesize)
34153415

34163416
#if defined(HAVE_FPATHCONF) || defined(HAVE_PATHCONF)
34173417
static struct constdef posix_constants_pathconf[] = {
3418+
#ifdef _PC_ABI_AIO_XFER_MAX
3419+
{"PC_ABI_AIO_XFER_MAX", _PC_ABI_AIO_XFER_MAX},
3420+
#endif
3421+
#ifdef _PC_ABI_ASYNC_IO
3422+
{"PC_ABI_ASYNC_IO", _PC_ABI_ASYNC_IO},
3423+
#endif
34183424
#ifdef _PC_ASYNC_IO
34193425
{"PC_ASYNC_IO", _PC_ASYNC_IO},
34203426
#endif
@@ -3540,6 +3546,21 @@ posix_pathconf(self, args)
35403546

35413547
#ifdef HAVE_CONFSTR
35423548
static struct constdef posix_constants_confstr[] = {
3549+
#ifdef _CS_ARCHITECTURE
3550+
{"CS_ARCHITECTURE", _CS_ARCHITECTURE},
3551+
#endif
3552+
#ifdef _CS_HOSTNAME
3553+
{"CS_HOSTNAME", _CS_HOSTNAME},
3554+
#endif
3555+
#ifdef _CS_HW_PROVIDER
3556+
{"CS_HW_PROVIDER", _CS_HW_PROVIDER},
3557+
#endif
3558+
#ifdef _CS_HW_SERIAL
3559+
{"CS_HW_SERIAL", _CS_HW_SERIAL},
3560+
#endif
3561+
#ifdef _CS_INITTAB_NAME
3562+
{"CS_INITTAB_NAME", _CS_INITTAB_NAME},
3563+
#endif
35433564
#ifdef _CS_LFS64_CFLAGS
35443565
{"CS_LFS64_CFLAGS", _CS_LFS64_CFLAGS},
35453566
#endif
@@ -3564,9 +3585,24 @@ static struct constdef posix_constants_confstr[] = {
35643585
#ifdef _CS_LFS_LINTFLAGS
35653586
{"CS_LFS_LINTFLAGS", _CS_LFS_LINTFLAGS},
35663587
#endif
3588+
#ifdef _CS_MACHINE
3589+
{"CS_MACHINE", _CS_MACHINE},
3590+
#endif
35673591
#ifdef _CS_PATH
35683592
{"CS_PATH", _CS_PATH},
35693593
#endif
3594+
#ifdef _CS_RELEASE
3595+
{"CS_RELEASE", _CS_RELEASE},
3596+
#endif
3597+
#ifdef _CS_SRPC_DOMAIN
3598+
{"CS_SRPC_DOMAIN", _CS_SRPC_DOMAIN},
3599+
#endif
3600+
#ifdef _CS_SYSNAME
3601+
{"CS_SYSNAME", _CS_SYSNAME},
3602+
#endif
3603+
#ifdef _CS_VERSION
3604+
{"CS_VERSION", _CS_VERSION},
3605+
#endif
35703606
#ifdef _CS_XBS5_ILP32_OFF32_CFLAGS
35713607
{"CS_XBS5_ILP32_OFF32_CFLAGS", _CS_XBS5_ILP32_OFF32_CFLAGS},
35723608
#endif
@@ -3615,6 +3651,45 @@ static struct constdef posix_constants_confstr[] = {
36153651
#ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
36163652
{"CS_XBS5_LPBIG_OFFBIG_LINTFLAGS", _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS},
36173653
#endif
3654+
#ifdef _MIPS_CS_AVAIL_PROCESSORS
3655+
{"MIPS_CS_AVAIL_PROCESSORS", _MIPS_CS_AVAIL_PROCESSORS},
3656+
#endif
3657+
#ifdef _MIPS_CS_BASE
3658+
{"MIPS_CS_BASE", _MIPS_CS_BASE},
3659+
#endif
3660+
#ifdef _MIPS_CS_HOSTID
3661+
{"MIPS_CS_HOSTID", _MIPS_CS_HOSTID},
3662+
#endif
3663+
#ifdef _MIPS_CS_HW_NAME
3664+
{"MIPS_CS_HW_NAME", _MIPS_CS_HW_NAME},
3665+
#endif
3666+
#ifdef _MIPS_CS_NUM_PROCESSORS
3667+
{"MIPS_CS_NUM_PROCESSORS", _MIPS_CS_NUM_PROCESSORS},
3668+
#endif
3669+
#ifdef _MIPS_CS_OSREL_MAJ
3670+
{"MIPS_CS_OSREL_MAJ", _MIPS_CS_OSREL_MAJ},
3671+
#endif
3672+
#ifdef _MIPS_CS_OSREL_MIN
3673+
{"MIPS_CS_OSREL_MIN", _MIPS_CS_OSREL_MIN},
3674+
#endif
3675+
#ifdef _MIPS_CS_OSREL_PATCH
3676+
{"MIPS_CS_OSREL_PATCH", _MIPS_CS_OSREL_PATCH},
3677+
#endif
3678+
#ifdef _MIPS_CS_OS_NAME
3679+
{"MIPS_CS_OS_NAME", _MIPS_CS_OS_NAME},
3680+
#endif
3681+
#ifdef _MIPS_CS_OS_PROVIDER
3682+
{"MIPS_CS_OS_PROVIDER", _MIPS_CS_OS_PROVIDER},
3683+
#endif
3684+
#ifdef _MIPS_CS_PROCESSORS
3685+
{"MIPS_CS_PROCESSORS", _MIPS_CS_PROCESSORS},
3686+
#endif
3687+
#ifdef _MIPS_CS_SERIAL
3688+
{"MIPS_CS_SERIAL", _MIPS_CS_SERIAL},
3689+
#endif
3690+
#ifdef _MIPS_CS_VENDOR
3691+
{"MIPS_CS_VENDOR", _MIPS_CS_VENDOR},
3692+
#endif
36183693
};
36193694

36203695
static int
@@ -3697,6 +3772,12 @@ static struct constdef posix_constants_sysconf[] = {
36973772
#ifdef _SC_2_VERSION
36983773
{"SC_2_VERSION", _SC_2_VERSION},
36993774
#endif
3775+
#ifdef _SC_ABI_ASYNCHRONOUS_IO
3776+
{"SC_ABI_ASYNCHRONOUS_IO", _SC_ABI_ASYNCHRONOUS_IO},
3777+
#endif
3778+
#ifdef _SC_ACL
3779+
{"SC_ACL", _SC_ACL},
3780+
#endif
37003781
#ifdef _SC_AIO_LISTIO_MAX
37013782
{"SC_AIO_LISTIO_MAX", _SC_AIO_LISTIO_MAX},
37023783
#endif
@@ -3718,6 +3799,9 @@ static struct constdef posix_constants_sysconf[] = {
37183799
#ifdef _SC_ATEXIT_MAX
37193800
{"SC_ATEXIT_MAX", _SC_ATEXIT_MAX},
37203801
#endif
3802+
#ifdef _SC_AUDIT
3803+
{"SC_AUDIT", _SC_AUDIT},
3804+
#endif
37213805
#ifdef _SC_AVPHYS_PAGES
37223806
{"SC_AVPHYS_PAGES", _SC_AVPHYS_PAGES},
37233807
#endif
@@ -3733,6 +3817,9 @@ static struct constdef posix_constants_sysconf[] = {
37333817
#ifdef _SC_BC_STRING_MAX
37343818
{"SC_BC_STRING_MAX", _SC_BC_STRING_MAX},
37353819
#endif
3820+
#ifdef _SC_CAP
3821+
{"SC_CAP", _SC_CAP},
3822+
#endif
37363823
#ifdef _SC_CHARCLASS_NAME_MAX
37373824
{"SC_CHARCLASS_NAME_MAX", _SC_CHARCLASS_NAME_MAX},
37383825
#endif
@@ -3802,6 +3889,9 @@ static struct constdef posix_constants_sysconf[] = {
38023889
#ifdef _SC_ICACHE_SZ
38033890
{"SC_ICACHE_SZ", _SC_ICACHE_SZ},
38043891
#endif
3892+
#ifdef _SC_INF
3893+
{"SC_INF", _SC_INF},
3894+
#endif
38053895
#ifdef _SC_INT_MAX
38063896
{"SC_INT_MAX", _SC_INT_MAX},
38073897
#endif
@@ -3811,9 +3901,18 @@ static struct constdef posix_constants_sysconf[] = {
38113901
#ifdef _SC_IOV_MAX
38123902
{"SC_IOV_MAX", _SC_IOV_MAX},
38133903
#endif
3904+
#ifdef _SC_IP_SECOPTS
3905+
{"SC_IP_SECOPTS", _SC_IP_SECOPTS},
3906+
#endif
38143907
#ifdef _SC_JOB_CONTROL
38153908
{"SC_JOB_CONTROL", _SC_JOB_CONTROL},
38163909
#endif
3910+
#ifdef _SC_KERN_POINTERS
3911+
{"SC_KERN_POINTERS", _SC_KERN_POINTERS},
3912+
#endif
3913+
#ifdef _SC_KERN_SIM
3914+
{"SC_KERN_SIM", _SC_KERN_SIM},
3915+
#endif
38173916
#ifdef _SC_LINE_MAX
38183917
{"SC_LINE_MAX", _SC_LINE_MAX},
38193918
#endif
@@ -3826,6 +3925,9 @@ static struct constdef posix_constants_sysconf[] = {
38263925
#ifdef _SC_LONG_BIT
38273926
{"SC_LONG_BIT", _SC_LONG_BIT},
38283927
#endif
3928+
#ifdef _SC_MAC
3929+
{"SC_MAC", _SC_MAC},
3930+
#endif
38293931
#ifdef _SC_MAPPED_FILES
38303932
{"SC_MAPPED_FILES", _SC_MAPPED_FILES},
38313933
#endif
@@ -3847,12 +3949,18 @@ static struct constdef posix_constants_sysconf[] = {
38473949
#ifdef _SC_MESSAGE_PASSING
38483950
{"SC_MESSAGE_PASSING", _SC_MESSAGE_PASSING},
38493951
#endif
3952+
#ifdef _SC_MMAP_FIXED_ALIGNMENT
3953+
{"SC_MMAP_FIXED_ALIGNMENT", _SC_MMAP_FIXED_ALIGNMENT},
3954+
#endif
38503955
#ifdef _SC_MQ_OPEN_MAX
38513956
{"SC_MQ_OPEN_MAX", _SC_MQ_OPEN_MAX},
38523957
#endif
38533958
#ifdef _SC_MQ_PRIO_MAX
38543959
{"SC_MQ_PRIO_MAX", _SC_MQ_PRIO_MAX},
38553960
#endif
3961+
#ifdef _SC_NACLS_MAX
3962+
{"SC_NACLS_MAX", _SC_NACLS_MAX},
3963+
#endif
38563964
#ifdef _SC_NGROUPS_MAX
38573965
{"SC_NGROUPS_MAX", _SC_NGROUPS_MAX},
38583966
#endif
@@ -3880,6 +3988,12 @@ static struct constdef posix_constants_sysconf[] = {
38803988
#ifdef _SC_NPROCESSORS_ONLN
38813989
{"SC_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN},
38823990
#endif
3991+
#ifdef _SC_NPROC_CONF
3992+
{"SC_NPROC_CONF", _SC_NPROC_CONF},
3993+
#endif
3994+
#ifdef _SC_NPROC_ONLN
3995+
{"SC_NPROC_ONLN", _SC_NPROC_ONLN},
3996+
#endif
38833997
#ifdef _SC_NZERO
38843998
{"SC_NZERO", _SC_NZERO},
38853999
#endif
@@ -3985,6 +4099,9 @@ static struct constdef posix_constants_sysconf[] = {
39854099
#ifdef _SC_SIGRT_MIN
39864100
{"SC_SIGRT_MIN", _SC_SIGRT_MIN},
39874101
#endif
4102+
#ifdef _SC_SOFTPOWER
4103+
{"SC_SOFTPOWER", _SC_SOFTPOWER},
4104+
#endif
39884105
#ifdef _SC_SPLIT_CACHE
39894106
{"SC_SPLIT_CACHE", _SC_SPLIT_CACHE},
39904107
#endif
@@ -4159,6 +4276,59 @@ posix_sysconf(self, args)
41594276
#endif
41604277

41614278

4279+
#ifdef CHECK_CONFNAME_TABLES
4280+
/* This code should not be enabled by default; it's only purpose is to
4281+
* test the order of constants in the configuration name tables. The
4282+
* second function defined here, check_confname_tables(), is called
4283+
* during module initialization if CHECK_CONFNAME_TABLES is defined.
4284+
* This only needs to be done when changes are made to the tables.
4285+
*/
4286+
static void
4287+
check_confname_table(table, tablesize, tablename)
4288+
struct constdef *table;
4289+
size_t tablesize;
4290+
char *tablename;
4291+
{
4292+
if (tablesize > 1) {
4293+
int i = 0;
4294+
4295+
for (; i < (tablesize - 1); ++i) {
4296+
if (strcmp(table[i].name, table[i + 1].name) >= 0) {
4297+
char buffer[256];
4298+
4299+
snprintf(buffer, sizeof(buffer),
4300+
"confname table '%s' out of order!\n", tablename);
4301+
Py_FatalError(buffer);
4302+
}
4303+
}
4304+
}
4305+
}
4306+
4307+
static void
4308+
check_confname_tables()
4309+
{
4310+
#if defined(HAVE_FPATHCONF) || defined(HAVE_PATHCONF)
4311+
check_confname_table(posix_constants_pathconf,
4312+
sizeof(posix_constants_pathconf)
4313+
/ sizeof(struct constdef),
4314+
"pathconf");
4315+
#endif
4316+
#ifdef HAVE_CONFSTR
4317+
check_confname_table(posix_constants_confstr,
4318+
sizeof(posix_constants_confstr)
4319+
/ sizeof(struct constdef),
4320+
"confstr");
4321+
#endif
4322+
#ifdef HAVE_SYSCONF
4323+
check_confname_table(posix_constants_sysconf,
4324+
sizeof(posix_constants_sysconf)
4325+
/ sizeof(struct constdef),
4326+
"sysconf");
4327+
#endif
4328+
}
4329+
#endif
4330+
4331+
41624332
static char posix_abort__doc__[] = "\
41634333
abort() -> does not return!\n\
41644334
Abort the interpreter immediately. This 'dumps core' or otherwise fails\n\
@@ -4576,4 +4746,8 @@ INITFUNC()
45764746
PyDict_SetItemString(d, "error", PyExc_OSError);
45774747

45784748
posix_putenv_garbage = PyDict_New();
4749+
4750+
#ifdef CHECK_CONFNAME_TABLES
4751+
check_confname_tables();
4752+
#endif
45794753
}

0 commit comments

Comments
 (0)