From 948623f0865c4b18a86ec4668d83d85bfcfc0a70 Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Wed, 22 Dec 2010 20:25:34 +0000 Subject: [PATCH] ok, this compiles on windows now --- src/common/bitstring.c | 2 +- src/common/hostlist.c | 2 +- src/common/node_conf.c | 2 +- src/common/node_select.c | 16 +- src/common/parse_config.c | 12 +- src/common/parse_time.c | 8 +- src/common/plugin.c | 4 +- src/common/plugstack.c | 6 +- src/common/proc_args.c | 36 ++--- src/common/read_config.c | 4 +- src/common/slurm_resource_info.c | 4 +- src/common/stepd_api.c | 2 +- src/common/xstring.c | 4 +- .../filetxt/filetxt_jobacct_process.c | 1 + .../slurmdbd/accounting_storage_slurmdbd.c | 2 + src/plugins/auth/munge/auth_munge.c | 2 +- .../multifactor/priority_multifactor.c | 2 +- src/plugins/select/bgq/select_bgq.cc | 2 +- .../select/bluegene/plugin/select_bluegene.c | 2 +- src/plugins/select/cray/select_cray.c | 2 +- src/slurmctld/groups.c | 6 +- src/slurmd/slurmd/get_mach_stat.c | 148 ++++++++++-------- src/slurmd/slurmd/req.c | 4 +- src/slurmd/slurmstepd/pdebug.c | 6 + 24 files changed, 155 insertions(+), 124 deletions(-) diff --git a/src/common/bitstring.c b/src/common/bitstring.c index 6363ddf9db1..8fed9d4cd29 100644 --- a/src/common/bitstring.c +++ b/src/common/bitstring.c @@ -1117,7 +1117,7 @@ int bit_unfmt_hexmask(bitstr_t * bitmap, const char* str) int bit_index = 0, len = strlen(str); int rc = 0; const char *curpos = str + len - 1; - char current; + int current; bitoff_t bitsize = bit_size(bitmap); bit_nclear(bitmap, 0, bitsize - 1); diff --git a/src/common/hostlist.c b/src/common/hostlist.c index c624db7ee3f..cf2e74f7996 100644 --- a/src/common/hostlist.c +++ b/src/common/hostlist.c @@ -618,7 +618,7 @@ static int host_prefix_end(const char *hostname) return -1; idx = len - 1; - while (idx >= 0 && isdigit((char) hostname[idx])) + while (idx >= 0 && isdigit((int)hostname[idx])) idx--; } diff --git a/src/common/node_conf.c b/src/common/node_conf.c index 4aff65daad0..9a485c5fb72 100644 --- a/src/common/node_conf.c +++ b/src/common/node_conf.c @@ -543,7 +543,7 @@ extern void build_config_feature_list(struct config_record *config_ptr) tmp_str = xmalloc(i); /* Remove white space from feature specification */ for (i=0, j=0; config_ptr->feature[i]; i++) { - if (!isspace(config_ptr->feature[i])) + if (!isspace((int)config_ptr->feature[i])) tmp_str[j++] = config_ptr->feature[i]; } if (i != j) diff --git a/src/common/node_select.c b/src/common/node_select.c index 13e2f8d769d..bc2de083a0d 100644 --- a/src/common/node_select.c +++ b/src/common/node_select.c @@ -286,11 +286,21 @@ extern int slurm_select_init(bool only_default) if (strncmp(e->d_name, "select_", 7)) continue; - len = strlen(e->d_name)-3; + len = strlen(e->d_name); +#if defined(__CYGWIN__) + len -= 4; +#else + len -= 3; +#endif /* Check only shared object files */ - if (strcmp(e->d_name+len, ".so")) + if (strcmp(e->d_name+len, +#if defined(__CYGWIN__) + ".dll" +#else + ".so" +#endif + )) continue; - /* add one for the / */ len++; xassert(len<sizeof(full_name)); diff --git a/src/common/parse_config.c b/src/common/parse_config.c index 51b026cc56c..b6cf948e668 100644 --- a/src/common/parse_config.c +++ b/src/common/parse_config.c @@ -99,7 +99,7 @@ static int _conf_hashtbl_index(const char *key) for (i = 0; i < 10; i++) { if (key[i] == '\0') break; - idx += tolower(key[i]); + idx += tolower((int)key[i]); } return idx % CONF_HASH_LEN; } @@ -266,7 +266,7 @@ static int _strip_continuation(char *buf, int len) for (ptr = buf+len-1; ptr >= buf; ptr--) { if (*ptr == '\\') bs++; - else if (isspace(*ptr) && bs == 0) + else if (isspace((int)*ptr) && bs == 0) continue; else break; @@ -725,7 +725,7 @@ static int _line_is_space(const char *line) } len = strlen(line); for (i = 0; i < len; i++) { - if (!isspace(line[i])) + if (!isspace((int)line[i])) return 0; } @@ -812,12 +812,12 @@ static int _parse_include_directive(s_p_hashtbl_t *hashtbl, uint32_t *hash_val, *leftover = NULL; if (strncasecmp("include", line, strlen("include")) == 0) { ptr = (char *)line + strlen("include"); - if (!isspace(*ptr)) + if (!isspace((int)*ptr)) return 0; - while (isspace(*ptr)) + while (isspace((int)*ptr)) ptr++; fn_start = ptr; - while (!isspace(*ptr)) + while (!isspace((int)*ptr)) ptr++; fn_stop = *leftover = ptr; filename = xstrndup(fn_start, fn_stop-fn_start); diff --git a/src/common/parse_time.c b/src/common/parse_time.c index 5fecb9a42a4..9bbdd7f3831 100644 --- a/src/common/parse_time.c +++ b/src/common/parse_time.c @@ -92,7 +92,7 @@ static int _get_delta(char *time_str, int *pos, long *delta) for (offset = (*pos) + 1; ((time_str[offset] != '\0') && (time_str[offset] != '\n')); offset++) { - if (isspace(time_str[offset])) + if (isspace((int)time_str[offset])) continue; for (i=0; un[i].name; i++) { if (!strncasecmp((time_str + offset), @@ -180,7 +180,7 @@ _get_time(char *time_str, int *pos, int *hour, int *minute, int * second) } else sec = 0; - while (isspace(time_str[offset])) { + while (isspace((int)time_str[offset])) { offset++; } if (strncasecmp(time_str+offset, "pm", 2)== 0) { @@ -357,7 +357,7 @@ extern time_t parse_time(char *time_str, int past) for (pos=0; ((time_str[pos] != '\0') && (time_str[pos] != '\n')); pos++) { - if (isblank(time_str[pos]) || + if (isblank((int)time_str[pos]) || (time_str[pos] == '-') || (time_str[pos] == 'T')) continue; if (strncasecmp(time_str+pos, "today", 5) == 0) { @@ -409,7 +409,7 @@ extern time_t parse_time(char *time_str, int past) goto prob; break; } - if (isblank(time_str[i])) + if (isblank((int)time_str[i])) continue; if ((time_str[i] == '\0') || (time_str[i] == '\n')) { diff --git a/src/common/plugin.c b/src/common/plugin.c index 6f9ce6c983b..3677337f75e 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -217,8 +217,8 @@ plugin_load_and_link(const char *type_name, int n_syms, if (!type_name) return plug; -#ifdef HAVE_WINDOWS - so_name = xstrdup_printf("%s.dll.a", type_name); +#if defined(__CYGWIN__) + so_name = xstrdup_printf("%s.dll", type_name); #else so_name = xstrdup_printf("%s.so", type_name); #endif diff --git a/src/common/plugstack.c b/src/common/plugstack.c index 98e66f232e0..e7717bcf910 100644 --- a/src/common/plugstack.c +++ b/src/common/plugstack.c @@ -1036,7 +1036,7 @@ _find_word_boundary(char *str, char *from, char **next) * Back up past any non-whitespace if we are pointing in * the middle of a word. */ - while ((p != str) && !isspace (*p)) + while ((p != str) && !isspace ((int)*p)) --p; /* @@ -1047,7 +1047,7 @@ _find_word_boundary(char *str, char *from, char **next) /* * Now move back to the end of the previous word */ - while ((p != str) && isspace (*p)) + while ((p != str) && isspace ((int)*p)) --p; if (p == str) { @@ -1182,7 +1182,7 @@ int spank_print_options(FILE * fp, int left_pad, int width) static char _canonical_char (char c) { - if (!isalnum (c)) + if (!isalnum ((int)c)) return '_'; else return c; diff --git a/src/common/proc_args.c b/src/common/proc_args.c index e48d430511e..7901c784e7d 100644 --- a/src/common/proc_args.c +++ b/src/common/proc_args.c @@ -141,7 +141,7 @@ task_dist_states_t verify_dist_type(const char *arg, uint32_t *plane_size) } else if (strncasecmp(arg, "block", len) == 0) { result = SLURM_DIST_BLOCK; } else if ((strncasecmp(arg, "arbitrary", len) == 0) || - (strncasecmp(arg, "hostfile", len) == 0)) { + (strncasecmp(arg, "hostfile", len) == 0)) { result = SLURM_DIST_ARBITRARY; } } @@ -378,7 +378,7 @@ bool verify_node_list(char **node_list_pptr, enum task_dist_states dist, saying, lay it out this way! */ if(dist == SLURM_DIST_ARBITRARY) nodelist = slurm_read_hostfile(*node_list_pptr, task_count); - else + else nodelist = slurm_read_hostfile(*node_list_pptr, NO_VAL); if (!nodelist) @@ -417,7 +417,7 @@ bool get_resource_arg_range(const char *arg, const char *what, int* min, } result = strtol(arg, &p, 10); - if (*p == 'k' || *p == 'K') { + if (*p == 'k' || *p == 'K') { result *= 1024; p++; } else if(*p == 'm' || *p == 'M') { @@ -445,7 +445,7 @@ bool get_resource_arg_range(const char *arg, const char *what, int* min, p++; result = strtol(p, &p, 10); - if ((*p == 'k') || (*p == 'K')) { + if ((*p == 'k') || (*p == 'K')) { result *= 1024; p++; } else if(*p == 'm' || *p == 'M') { @@ -514,7 +514,7 @@ bool verify_socket_core_thread_count(const char *arg, int *min_sockets, } else if (j == 2) { *cpu_bind_type |= CPU_BIND_TO_THREADS; } - } + } buf[j][i] = '\0'; ret_val = true; @@ -544,7 +544,7 @@ bool verify_socket_core_thread_count(const char *arg, int *min_sockets, * RET true if valid */ bool verify_hint(const char *arg, int *min_sockets, int *min_cores, - int *min_threads, int *ntasks_per_core, + int *min_threads, int *ntasks_per_core, cpu_bind_type_t *cpu_bind_type) { char *buf, *p, *tok; @@ -557,7 +557,7 @@ bool verify_hint(const char *arg, int *min_sockets, int *min_cores, /* change all ',' delimiters not followed by a digit to ';' */ /* simplifies parsing tokens while keeping map/mask together */ while (p[0] != '\0') { - if ((p[0] == ',') && (!isdigit(p[1]))) + if ((p[0] == ',') && (!isdigit((int)p[1]))) p[0] = ';'; p++; } @@ -574,21 +574,21 @@ bool verify_hint(const char *arg, int *min_sockets, int *min_cores, " help show this help message\n"); return 1; } else if (strcasecmp(tok, "compute_bound") == 0) { - *min_sockets = NO_VAL; - *min_cores = NO_VAL; - *min_threads = 1; + *min_sockets = NO_VAL; + *min_cores = NO_VAL; + *min_threads = 1; *cpu_bind_type |= CPU_BIND_TO_CORES; } else if (strcasecmp(tok, "memory_bound") == 0) { - *min_cores = 1; - *min_threads = 1; + *min_cores = 1; + *min_threads = 1; *cpu_bind_type |= CPU_BIND_TO_CORES; } else if (strcasecmp(tok, "multithread") == 0) { - *min_threads = NO_VAL; + *min_threads = NO_VAL; *cpu_bind_type |= CPU_BIND_TO_THREADS; if (*ntasks_per_core == NO_VAL) *ntasks_per_core = INFINITE; } else if (strcasecmp(tok, "nomultithread") == 0) { - *min_threads = 1; + *min_threads = 1; *cpu_bind_type |= CPU_BIND_TO_THREADS; } else { error("unrecognized --hint argument \"%s\", " @@ -615,7 +615,7 @@ uint16_t parse_mail_type(const char *arg) else if (strcasecmp(arg, "REQUEUE") == 0) rc = MAIL_JOB_REQUEUE; else if (strcasecmp(arg, "ALL") == 0) - rc = MAIL_JOB_BEGIN | MAIL_JOB_END | MAIL_JOB_FAIL | + rc = MAIL_JOB_BEGIN | MAIL_JOB_END | MAIL_JOB_FAIL | MAIL_JOB_REQUEUE; else rc = 0; /* failure */ @@ -690,7 +690,7 @@ search_path(char *cwd, char *cmd, bool check_current_dir, int access_mode) char *path, *fullpath = NULL; if ( (cmd[0] == '.' || cmd[0] == '/') - && (access(cmd, access_mode) == 0 ) ) { + && (access(cmd, access_mode) == 0 ) ) { if (cmd[0] == '.') xstrfmtcat(fullpath, "%s/", cwd); xstrcat(fullpath, cmd); @@ -813,7 +813,7 @@ int sig_name2num(char *signal_name) return 0; } else { ptr = (char *)signal_name; - while (isspace(*ptr)) + while (isspace((int)*ptr)) ptr++; if (strncasecmp(ptr, "SIG", 3) == 0) ptr += 3; @@ -823,7 +823,7 @@ int sig_name2num(char *signal_name) if (strncasecmp(ptr, sig_name[i], strlen(sig_name[i])) == 0) { /* found the signal name */ - if (!xstring_is_whitespace(ptr + + if (!xstring_is_whitespace(ptr + strlen(sig_name[i]))) return 0; sig = sig_num[i]; diff --git a/src/common/read_config.c b/src/common/read_config.c index f37bb3e461a..dd4a7574dd4 100644 --- a/src/common/read_config.c +++ b/src/common/read_config.c @@ -731,7 +731,7 @@ static int _parse_partitionname(void **dest, slurm_parser_enum_t type, else { int i; for (i=0; p->nodes[i]; i++) { - if (isspace(p->nodes[i])) + if (isspace((int)p->nodes[i])) p->nodes[i] = ','; } } @@ -1879,7 +1879,7 @@ _validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl) int i; for (i = 0; conf->cluster_name[i] != '\0'; i++) conf->cluster_name[i] = - (char)tolower(conf->cluster_name[i]); + (char)tolower((int)conf->cluster_name[i]); } if (!s_p_get_uint16(&conf->complete_wait, "CompleteWait", hashtbl)) diff --git a/src/common/slurm_resource_info.c b/src/common/slurm_resource_info.c index 80dd2caec67..537ca7fdda5 100644 --- a/src/common/slurm_resource_info.c +++ b/src/common/slurm_resource_info.c @@ -72,11 +72,11 @@ static void _clear_then_set(int *data, int clear_mask, int set_mask) * returns 1 is the argument appears to be a value, 0 otherwise */ static int _isvalue(char *arg) { - if (isdigit(*arg)) { /* decimal values and 0x... hex values */ + if (isdigit((int)*arg)) { /* decimal values and 0x... hex values */ return 1; } - while (isxdigit(*arg)) { /* hex values not preceded by 0x */ + while (isxdigit((int)*arg)) { /* hex values not preceded by 0x */ arg++; } if (*arg == ',' || *arg == '\0') { /* end of field or string */ diff --git a/src/common/stepd_api.c b/src/common/stepd_api.c index a0bc4e86442..7eea47b2595 100644 --- a/src/common/stepd_api.c +++ b/src/common/stepd_api.c @@ -108,7 +108,7 @@ _handle_stray_socket(const char *socket_name) if ((uid = getuid()) != buf.st_uid) { debug3("_handle_stray_socket: socket %s is not owned by uid %d", - socket_name, uid); + socket_name, (int)uid); return; } diff --git a/src/common/xstring.c b/src/common/xstring.c index 020a2fcb3be..ba53f31ae55 100644 --- a/src/common/xstring.c +++ b/src/common/xstring.c @@ -470,7 +470,7 @@ bool xstring_is_whitespace(const char *str) len = strlen(str); for (i = 0; i < len; i++) { - if (!isspace(str[i])) { + if (!isspace((int)str[i])) { return false; } } @@ -486,7 +486,7 @@ char *xstrtolower(char *str) if(str) { int j = 0; while(str[j]) { - str[j] = tolower(str[j]); + str[j] = tolower((int)str[j]); j++; } } diff --git a/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c b/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c index e9509603611..ba35c156d37 100644 --- a/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c +++ b/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c @@ -46,6 +46,7 @@ #include "src/common/xstring.h" #include "src/common/xmalloc.h" +#include "src/common/list.h" #include "filetxt_jobacct_process.h" #include "src/slurmctld/slurmctld.h" #include "src/slurmdbd/read_config.h" diff --git a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c index 6d9064d9cfe..aeee11b1990 100644 --- a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c +++ b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c @@ -67,8 +67,10 @@ * the slurmctld we will have these symbols defined. They will get * overwritten when linking with the slurmctld. */ +#if !defined(__CYGWIN__) slurm_ctl_conf_t slurmctld_conf; List job_list = NULL; +#endif /* * These variables are required by the generic plugin interface. If they diff --git a/src/plugins/auth/munge/auth_munge.c b/src/plugins/auth/munge/auth_munge.c index f898067e8b7..36e934a864a 100644 --- a/src/plugins/auth/munge/auth_munge.c +++ b/src/plugins/auth/munge/auth_munge.c @@ -69,8 +69,8 @@ #include <munge.h> -#include <slurm/slurm_errno.h> #include "src/common/slurm_xlator.h" +#include <slurm/slurm_errno.h> #define MUNGE_ERRNO_OFFSET 1000 diff --git a/src/plugins/priority/multifactor/priority_multifactor.c b/src/plugins/priority/multifactor/priority_multifactor.c index 8b5417cb473..bdaee3fbf29 100644 --- a/src/plugins/priority/multifactor/priority_multifactor.c +++ b/src/plugins/priority/multifactor/priority_multifactor.c @@ -73,7 +73,7 @@ uint32_t cluster_cpus __attribute__((weak_import)) = NO_VAL; List job_list __attribute__((weak_import)) = NULL; time_t last_job_update __attribute__((weak_import)); -#else +#elif !defined (__CYGWIN__) uint32_t cluster_cpus = NO_VAL; List job_list = NULL; time_t last_job_update; diff --git a/src/plugins/select/bgq/select_bgq.cc b/src/plugins/select/bgq/select_bgq.cc index d017bc01195..0b84e7cf4ec 100644 --- a/src/plugins/select/bgq/select_bgq.cc +++ b/src/plugins/select/bgq/select_bgq.cc @@ -59,7 +59,7 @@ char *alpha_num __attribute__((weak_import)) = void *acct_db_conn __attribute__((weak_import)) = NULL; char *slurmctld_cluster_name __attribute__((weak_import)) = NULL; slurmdb_cluster_rec_t *working_cluster_rec __attribute__((weak_import)) = NULL; -#else +#elif !defined(__CYGWIN__) slurm_ctl_conf_t slurmctld_conf; struct node_record *node_record_table_ptr = NULL; int bg_recover = NOT_FROM_CONTROLLER; diff --git a/src/plugins/select/bluegene/plugin/select_bluegene.c b/src/plugins/select/bluegene/plugin/select_bluegene.c index 113d961b408..7259aed2868 100644 --- a/src/plugins/select/bluegene/plugin/select_bluegene.c +++ b/src/plugins/select/bluegene/plugin/select_bluegene.c @@ -65,7 +65,7 @@ char *alpha_num __attribute__((weak_import)) = void *acct_db_conn __attribute__((weak_import)) = NULL; char *slurmctld_cluster_name __attribute__((weak_import)) = NULL; slurmdb_cluster_rec_t *working_cluster_rec __attribute__((weak_import)) = NULL; -#else +#elif !defined(__CYGWIN__) slurm_ctl_conf_t slurmctld_conf; struct node_record *node_record_table_ptr = NULL; int bg_recover = NOT_FROM_CONTROLLER; diff --git a/src/plugins/select/cray/select_cray.c b/src/plugins/select/cray/select_cray.c index 5eff8fbacbc..00e81b76f9d 100644 --- a/src/plugins/select/cray/select_cray.c +++ b/src/plugins/select/cray/select_cray.c @@ -69,7 +69,7 @@ int node_record_count __attribute__((weak_import)); time_t last_node_update __attribute__((weak_import)); struct switch_record *switch_record_table __attribute__((weak_import)); int switch_record_cnt __attribute__((weak_import)); -#else +#elif !defined(__CYGWIN__) slurm_ctl_conf_t slurmctld_conf; struct node_record *node_record_table_ptr; int bg_recover = NOT_FROM_CONTROLLER; diff --git a/src/slurmctld/groups.c b/src/slurmctld/groups.c index c0ad117d665..fdc831b47dc 100644 --- a/src/slurmctld/groups.c +++ b/src/slurmctld/groups.c @@ -93,7 +93,7 @@ extern uid_t *get_group_members(char *group_name) int i, j, uid_cnt; #ifdef HAVE_AIX FILE *fp = NULL; -#elif defined (__APPLE__) +#elif defined (__APPLE__) || defined (__CYGWIN__) #else char pw_buffer[PW_BUF_SIZE]; struct passwd pw; @@ -121,7 +121,7 @@ extern uid_t *get_group_members(char *group_name) setgrent_r(&fp); while (!getgrent_r(&grp, grp_buffer, PW_BUF_SIZE, &fp)) { grp_result = &grp; -#elif defined (__APPLE__) +#elif defined (__APPLE__) || defined (__CYGWIN__) setgrent(); while ((grp_result = getgrent()) != NULL) { #else @@ -166,7 +166,7 @@ extern uid_t *get_group_members(char *group_name) setpwent(); #if defined (__sun) while ((pwd_result = getpwent_r(&pw, pw_buffer, PW_BUF_SIZE)) != NULL) { -#elif defined (__APPLE__) +#elif defined (__APPLE__) || defined (__CYGWIN__) while ((pwd_result = getpwent()) != NULL) { #else while (!getpwent_r(&pw, pw_buffer, PW_BUF_SIZE, &pwd_result)) { diff --git a/src/slurmd/slurmd/get_mach_stat.c b/src/slurmd/slurmd/get_mach_stat.c index ed3edefcb71..e2fc60eeb9f 100644 --- a/src/slurmd/slurmd/get_mach_stat.c +++ b/src/slurmd/slurmd/get_mach_stat.c @@ -1,9 +1,9 @@ /*****************************************************************************\ - * get_mach_stat.c - Get the status of the current machine + * get_mach_stat.c - Get the status of the current machine * * NOTE: Some of these functions are system dependent. Built on RedHat2.4 * NOTE: While not currently used by SLURM, this code can also get a node's - * OS name and CPU speed. See code ifdef'ed out via USE_OS_NAME and + * OS name and CPU speed. See code ifdef'ed out via USE_OS_NAME and * USE_CPU_SPEED ***************************************************************************** * Copyright (C) 2006 Hewlett-Packard Development Company, L.P. @@ -11,32 +11,32 @@ * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Morris Jette <jette1@llnl.gov>. * CODE-OCEC-09-009. All rights reserved. - * + * * This file is part of SLURM, a resource management program. * For details, see <https://computing.llnl.gov/linux/slurm/>. * Please also read the included file: DISCLAIMER. - * + * * SLURM is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * - * In addition, as a special exception, the copyright holders give permission - * to link the code of portions of this program with the OpenSSL library under - * certain conditions as described in each individual source file, and - * distribute linked combinations including the two. You must obey the GNU - * General Public License in all respects for all of the code used other than - * OpenSSL. If you modify file(s) with this exception, you may extend this - * exception to your version of the file(s), but you are not obligated to do + * In addition, as a special exception, the copyright holders give permission + * to link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. You must obey the GNU + * General Public License in all respects for all of the code used other than + * OpenSSL. If you modify file(s) with this exception, you may extend this + * exception to your version of the file(s), but you are not obligated to do * so. If you do not wish to do so, delete this exception statement from your - * version. If you delete this exception statement from all source files in + * version. If you delete this exception statement from all source files in * the program, then also delete it here. - * + * * SLURM is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR 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 SLURM; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. @@ -57,9 +57,9 @@ #ifdef HAVE_SYS_SYSCTL_H # include <sys/sysctl.h> #endif - + #include <errno.h> -#include <fcntl.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -97,6 +97,7 @@ #include "src/slurmctld/slurmctld.h" #include "src/slurmd/slurmd/get_mach_stat.h" +static char* _uptime_path = "/proc/uptime"; static char* _cpuinfo_path = "/proc/cpuinfo"; static int _compute_block_map(uint16_t numproc, @@ -119,8 +120,8 @@ static int _chk_cpuinfo_uint32(char *buffer, char *keyword, uint32_t *val); #define xfree free /* main is used here for testing purposes only: */ /* % gcc -DDEBUG_MODULE get_mach_stat.c -I../../.. -g -DUSE_CPU_SPEED */ -int -main(int argc, char * argv[]) +int +main(int argc, char * argv[]) { int error_code; uint16_t sockets, cores, threads; @@ -140,7 +141,7 @@ main(int argc, char * argv[]) debug3("%s:", _cpuinfo_path); error_code = get_mach_name(node_name); - if (error_code != 0) + if (error_code != 0) exit(1); /* The show is all over without a node name */ error_code += get_procs(&this_node.cpus); @@ -171,15 +172,15 @@ main(int argc, char * argv[]) days = (up_time / 86400); debug3("\tUpTime=%u=%u-%2.2u:%2.2u:%2.2u", up_time, days, hours, mins, secs); - if (error_code != 0) + if (error_code != 0) debug3("get_mach_stat error_code=%d encountered", error_code); exit (error_code); } -/* gethostname_short - equivalent to gethostname, but return only the first - * component of the fully qualified name - * (e.g. "linux123.foo.bar" becomes "linux123") +/* gethostname_short - equivalent to gethostname, but return only the first + * component of the fully qualified name + * (e.g. "linux123.foo.bar" becomes "linux123") * OUT name */ int @@ -209,13 +210,13 @@ gethostname_short (char *name, size_t len) /* - * get_procs - Return the count of procs on this system + * get_procs - Return the count of procs on this system * Input: procs - buffer for the CPU count * Output: procs - filled in with CPU count, "1" if error * return code - 0 if no error, otherwise errno */ -extern int -get_procs(uint16_t *procs) +extern int +get_procs(uint16_t *procs) { #ifdef LPAR_INFO_FORMAT2 /* AIX 5.3 only */ @@ -226,7 +227,7 @@ get_procs(uint16_t *procs) error("lpar_get_info() failed"); return EINVAL; } - + *procs = (uint16_t) info.online_vcpus; #else /* !LPAR_INFO_FORMAT2 */ @@ -238,7 +239,7 @@ get_procs(uint16_t *procs) if (my_proc_tally < 1) { error ("get_procs: error running sysconf(_SC_NPROCESSORS_ONLN)"); return EINVAL; - } + } *procs = (uint16_t) my_proc_tally; # else @@ -263,13 +264,13 @@ get_procs(uint16_t *procs) #ifdef USE_OS_NAME /* - * get_os_name - Return the operating system name and version + * get_os_name - Return the operating system name and version * Input: os_name - buffer for the OS name, must be at least MAX_OS_LEN characters * Output: os_name - filled in with OS name, "UNKNOWN" if error * return code - 0 if no error, otherwise errno */ -extern int -get_os_name(char *os_name) +extern int +get_os_name(char *os_name) { int error_code; struct utsname sys_info; @@ -279,13 +280,13 @@ get_os_name(char *os_name) if (error_code != 0) { error ("get_os_name: uname error %d", error_code); return error_code; - } + } - if ((strlen(sys_info.sysname) + strlen(sys_info.release) + 2) >= + if ((strlen(sys_info.sysname) + strlen(sys_info.release) + 2) >= MAX_OS_LEN) { error ("get_os_name: OS name too long"); return error_code; - } + } strcpy(os_name, sys_info.sysname); strcat(os_name, "."); @@ -296,13 +297,13 @@ get_os_name(char *os_name) /* - * get_mach_name - Return the name of this node + * get_mach_name - Return the name of this node * Input: node_name - buffer for the node name, must be at least MAX_SLURM_NAME characters * Output: node_name - filled in with node name * return code - 0 if no error, otherwise errno */ -extern int -get_mach_name(char *node_name) +extern int +get_mach_name(char *node_name) { int error_code; @@ -315,7 +316,7 @@ get_mach_name(char *node_name) /* - * get_memory - Return the count of procs on this system + * get_memory - Return the count of procs on this system * Input: real_memory - buffer for the Real Memory size * Output: real_memory - the Real Memory size in MB, "1" if error * return code - 0 if no error, otherwise errno @@ -334,8 +335,8 @@ get_memory(uint32_t *real_memory) if (pages < 1) { error ("get_memory: error running sysconf(_SC_PHYS_PAGES)"); return EINVAL; - } - *real_memory = (uint32_t)((float)pages * (sysconf(_SC_PAGE_SIZE) / + } + *real_memory = (uint32_t)((float)pages * (sysconf(_SC_PAGE_SIZE) / 1048576.0)); /* Megabytes of memory */ # else /* !_SC_PHYS_PAGES */ # if HAVE_SYSCTLBYNAME @@ -357,16 +358,16 @@ get_memory(uint32_t *real_memory) /* - * get_tmp_disk - Return the total size of temporary file system on - * this system + * get_tmp_disk - Return the total size of temporary file system on + * this system * Input: tmp_disk - buffer for the disk space size - * tmp_fs - pathname of the temporary file system to status, - * defaults to "/tmp" + * tmp_fs - pathname of the temporary file system to status, + * defaults to "/tmp" * Output: tmp_disk - filled in with disk space size in MB, zero if error * return code - 0 if no error, otherwise errno */ -extern int -get_tmp_disk(uint32_t *tmp_disk, char *tmp_fs) +extern int +get_tmp_disk(uint32_t *tmp_disk, char *tmp_fs) { int error_code = 0; #ifdef HAVE_SYS_VFS_H @@ -390,7 +391,7 @@ get_tmp_disk(uint32_t *tmp_disk, char *tmp_fs) } else if (errno != ENOENT) { error_code = errno; - error ("get_tmp_disk: error %d executing statfs on %s", + error ("get_tmp_disk: error %d executing statfs on %s", errno, tmp_fs_name); } @@ -403,7 +404,7 @@ get_tmp_disk(uint32_t *tmp_disk, char *tmp_fs) extern int get_up_time(uint32_t *up_time) { -#if defined(HAVE_AIX) || defined(__sun) || defined(__APPLE__) +#if defined(HAVE_AIX) || defined(__sun) || defined(__APPLE__) clock_t tm; struct tms buf; @@ -414,10 +415,23 @@ extern int get_up_time(uint32_t *up_time) } *up_time = tm / sysconf(_SC_CLK_TCK); +#elif defined(__CYGWIN__) + FILE *uptime_file; + char buffer[128]; + + if (!(uptime_file = fopen(_uptime_path, "r"))) { + error("get_up_time: error %d opening %s", errno, _uptime_path); + return errno; + } + + if (fgets(buffer, sizeof(buffer), uptime_file)) + *up_time = atoi(buffer); + + fclose(uptime_file); #else - /* NOTE for Linux: The return value of times() may overflow the - * possible range of type clock_t. There is also an offset of - * 429 million seconds on some implementations. We just use the + /* NOTE for Linux: The return value of times() may overflow the + * possible range of type clock_t. There is also an offset of + * 429 million seconds on some implementations. We just use the * simpler sysinfo() function instead. */ struct sysinfo info; @@ -446,7 +460,7 @@ static int _chk_cpuinfo_str(char *buffer, char *keyword, char **valptr) return false; ptr = strstr(buffer, ":"); - if (ptr != NULL) + if (ptr != NULL) ptr++; *valptr = ptr; return true; @@ -496,8 +510,8 @@ static int _chk_cpuinfo_float(char *buffer, char *keyword, float *val) * Output: procs - filled in with CPU speed, "1.0" if error * return code - 0 if no error, otherwise errno */ -extern int -get_speed(float *speed) +extern int +get_speed(float *speed) { #if defined (__sun) kstat_ctl_t *kc; @@ -524,29 +538,29 @@ get_speed(float *speed) if (cpu_info_file == NULL) { error("get_speed: error %d opening %s", errno, _cpuinfo_path); return errno; - } + } while (fgets(buffer, sizeof(buffer), cpu_info_file) != NULL) { _chk_cpuinfo_float(buffer, "cpu MHz", speed); - } + } fclose(cpu_info_file); #endif return 0; -} +} #endif /* - * get_cpuinfo - Return detailed cpuinfo on this system + * get_cpuinfo - Return detailed cpuinfo on this system * Input: numproc - number of processors on the system * Output: p_sockets - number of physical processor sockets * p_cores - total number of physical CPU cores * p_threads - total number of hardware execution threads - * block_map - asbtract->physical block distribution map + * block_map - asbtract->physical block distribution map * block_map_inv - physical->abstract block distribution map (inverse) * return code - 0 if no error, otherwise errno - * NOTE: User must xfree block_map and block_map_inv + * NOTE: User must xfree block_map and block_map_inv */ typedef struct cpuinfo { uint16_t seen; @@ -616,7 +630,7 @@ get_cpuinfo(uint16_t numproc, #else cpu_info_file = fopen(_cpuinfo_path, "r"); if (cpu_info_file == NULL) { - error ("get_cpuinfo: error %d opening %s", + error ("get_cpuinfo: error %d opening %s", errno, _cpuinfo_path); return errno; } @@ -699,7 +713,7 @@ get_cpuinfo(uint16_t numproc, numcpu++; curcpu = val; if (val >= numproc) { /* out of bounds, ignore */ - debug("cpuid is %u (> %d), ignored", + debug("cpuid is %u (> %d), ignored", val, numproc); continue; } @@ -797,10 +811,10 @@ get_cpuinfo(uint16_t numproc, } if (sockets == 0) sockets = 1; /* guarantee non-zero */ - + cores = numcores / sockets; /* unique "core id" */ cores = MAX(maxcores, cores); /* maximum "cpu cores" */ - + if (cores == 0) { cores = numcpu / sockets; /* assume multi-core */ if (cores > 1) { @@ -810,7 +824,7 @@ get_cpuinfo(uint16_t numproc, } if (cores == 0) cores = 1; /* guarantee non-zero */ - + threads = numcpu / (sockets * cores); /* solve for threads */ if (threads == 0) threads = 1; /* guarantee non-zero */ @@ -871,7 +885,7 @@ get_cpuinfo(uint16_t numproc, * actual machine processor ID ordering (which can be BIOS/OS dependendent) * Input: numproc - number of processors on the system * cpu - array of cpuinfo (file static for qsort/_compare_cpus) - * Output: block_map, block_map_inv - asbtract->physical block distribution map + * Output: block_map, block_map_inv - asbtract->physical block distribution map * return code - 0 if no error, otherwise errno * NOTE: User must free block_map and block_map_inv * @@ -1024,5 +1038,3 @@ static int _compute_block_map(uint16_t numproc, #endif return 0; } - - diff --git a/src/slurmd/slurmd/req.c b/src/slurmd/slurmd/req.c index c6d71e2c38e..38bdc8f5429 100644 --- a/src/slurmd/slurmd/req.c +++ b/src/slurmd/slurmd/req.c @@ -3978,7 +3978,7 @@ init_gids_cache(int cache) gids_t *gids; #ifdef HAVE_AIX FILE *fp = NULL; -#elif defined (__APPLE__) +#elif defined (__APPLE__) || defined (__CYGWIN__) #else struct passwd pw; char buf[BUF_SIZE]; @@ -4008,7 +4008,7 @@ init_gids_cache(int cache) setpwent(); #if defined (__sun) while ((pwd = getpwent_r(&pw, buf, BUF_SIZE)) != NULL) { -#elif defined (__APPLE__) +#elif defined (__APPLE__) || defined (__CYGWIN__) while ((pwd = getpwent()) != NULL) { #else diff --git a/src/slurmd/slurmstepd/pdebug.c b/src/slurmd/slurmstepd/pdebug.c index f5a48ef9092..3e2972dbb92 100644 --- a/src/slurmd/slurmstepd/pdebug.c +++ b/src/slurmd/slurmstepd/pdebug.c @@ -101,6 +101,10 @@ pdebug_trace_process(slurmd_job_t *job, pid_t pid) if (_PTRACE(PT_DETACH, pid, NULL, 0)) { #elif defined(__sun) if (_PTRACE(7, pid, NULL, 0)) { +#elif defined(__CYGWIN__) + if (1) { + debug3("No ptrace for cygwin"); + } else { #else if (_PTRACE(PTRACE_DETACH, pid, NULL, 0)) { #endif @@ -127,6 +131,8 @@ pdebug_stop_current(slurmd_job_t *job) && (_PTRACE(PT_TRACE_ME, 0, NULL, 0) < 0) ) #elif defined(__sun) && (_PTRACE(0, 0, NULL, 0) < 0)) +#elif defined(__CYGWIN__) + && 0) #else && (_PTRACE(PTRACE_TRACEME, 0, NULL, 0) < 0) ) #endif -- GitLab