diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2012-07-13 09:51:28 -0700 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2012-07-13 09:51:28 -0700 |
commit | e3036ae4c9f79099fe14d6574fe259149fc6a397 (patch) | |
tree | 3e7c92d581abc506a08e2e7f9ab1bba078bb0ff2 | |
parent | 0ddc1c54f770fd9a91a75fcc99a74296ae9cda0f (diff) |
304.22304.22
-rw-r--r-- | Makefile | 17 | ||||
-rw-r--r-- | common-utils/common-utils.c | 60 | ||||
-rw-r--r-- | common-utils/common-utils.h | 2 | ||||
-rw-r--r-- | common-utils/nvgetopt.c | 3 | ||||
-rw-r--r-- | multiple_screens.c | 6 | ||||
-rw-r--r-- | nvidia-xconfig.h | 2 | ||||
-rw-r--r-- | option_table.h | 97 | ||||
-rw-r--r-- | util.c | 54 | ||||
-rw-r--r-- | utils.mk | 37 | ||||
-rw-r--r-- | version.mk | 2 |
10 files changed, 155 insertions, 125 deletions
@@ -80,13 +80,14 @@ SRC += $(addprefix $(COMMON_UTILS_DIR)/,$(COMMON_UTILS_SRC)) OBJS = $(call BUILD_OBJECT_LIST,$(SRC)) -CFLAGS += -I XF86Config-parser -CFLAGS += -I $(OUTPUTDIR) -CFLAGS += -I $(NVIDIA_CFG_DIR) -CFLAGS += -I $(COMMON_UTILS_DIR) -CFLAGS += -DPROGRAM_NAME=\"nvidia-xconfig\" +common_cflags += -I XF86Config-parser +common_cflags += -I $(OUTPUTDIR) +common_cflags += -I $(NVIDIA_CFG_DIR) +common_cflags += -I $(COMMON_UTILS_DIR) +common_cflags += -DPROGRAM_NAME=\"nvidia-xconfig\" -HOST_CFLAGS += $(CFLAGS) +CFLAGS += $(common_cflags) +HOST_CFLAGS += $(common_cflags) LIBS += -lm @@ -123,7 +124,7 @@ $(NVIDIA_XCONFIG): $(OBJS) $(call quiet_cmd,STRIP_CMD) $@ # define the rule to build each object file -$(foreach src, $(SRC), $(eval $(call DEFINE_OBJECT_RULE,CC,$(src)))) +$(foreach src, $(SRC), $(eval $(call DEFINE_OBJECT_RULE,TARGET,$(src)))) # define the rule to generate $(STAMP_C) $(eval $(call DEFINE_STAMP_C_RULE, $(OBJS),$(NVIDIA_XCONFIG_PROGRAM_NAME))) @@ -148,7 +149,7 @@ GEN_MANPAGE_OPTS_SRC += $(COMMON_UTILS_DIR)/gen-manpage-opts-helper.c GEN_MANPAGE_OPTS_OBJS = $(call BUILD_OBJECT_LIST,$(GEN_MANPAGE_OPTS_SRC)) $(foreach src, $(GEN_MANPAGE_OPTS_SRC), \ - $(eval $(call DEFINE_OBJECT_RULE,HOST_CC,$(src)))) + $(eval $(call DEFINE_OBJECT_RULE,HOST,$(src)))) $(GEN_MANPAGE_OPTS): $(GEN_MANPAGE_OPTS_OBJS) $(call quiet_cmd,HOST_LINK) \ diff --git a/common-utils/common-utils.c b/common-utils/common-utils.c index 98b92fe..a8ee75a 100644 --- a/common-utils/common-utils.c +++ b/common-utils/common-utils.c @@ -586,3 +586,63 @@ void fmt(FILE *stream, const char *prefix, const char *fmt, ...) } NV_VFORMAT(stream, TRUE, prefix, fmt); } + + +/* + * Read from the given FILE stream until a newline, EOF, or nul + * terminator is encountered, writing data into a growable buffer. + * The eof parameter is set to TRUE when EOF is encountered. In all + * cases, the returned string is null-terminated. + * + * XXX this function will be rather slow because it uses fgetc() to + * pull each character off the stream one at a time; this is done so + * that each character can be examined as it's read so that we can + * appropriately deal with EOFs and newlines. A better implementation + * would use fgets(), but that would still require us to parse each + * read line, checking for newlines or guessing if we hit an EOF. + */ +char *fget_next_line(FILE *fp, int *eof) +{ + char *buf = NULL, *tmpbuf; + char *c = NULL; + int len = 0, buflen = 0; + int ret; + + const int __fget_next_line_len = 32; + + if (eof) { + *eof = FALSE; + } + + while (1) { + if (buflen == len) { /* buffer isn't big enough -- grow it */ + buflen += __fget_next_line_len; + tmpbuf = nvalloc(buflen); + if (buf) { + memcpy(tmpbuf, buf, len); + nvfree(buf); + } + buf = tmpbuf; + c = buf + len; + } + + ret = fgetc(fp); + + if ((ret == EOF) && (eof)) { + *eof = TRUE; + } + + if ((ret == EOF) || (ret == '\n') || (ret == '\0')) { + *c = '\0'; + return buf; + } + + *c = (char) ret; + + len++; + c++; + + } /* while (1) */ + + return NULL; /* should never get here */ +} diff --git a/common-utils/common-utils.h b/common-utils/common-utils.h index e0d9314..c5cd411 100644 --- a/common-utils/common-utils.h +++ b/common-utils/common-utils.h @@ -65,6 +65,8 @@ void fmterr(const char *fmt, ...); void fmtwarn(const char *fmt, ...); void fmt(FILE *stream, const char *prefix, const char *fmt, ...); +char *fget_next_line(FILE *fp, int *eof); + /* * NV_VSNPRINTF(): macro that assigns buf using vsnprintf(). This is * correct for differing semantics of the vsnprintf() return value: diff --git a/common-utils/nvgetopt.c b/common-utils/nvgetopt.c index f04cef3..1c6c9b8 100644 --- a/common-utils/nvgetopt.c +++ b/common-utils/nvgetopt.c @@ -22,6 +22,7 @@ #include <string.h> #include <stdlib.h> #include <ctype.h> +#include <limits.h> #include "nvgetopt.h" #include "common-utils.h" @@ -401,7 +402,7 @@ void nvgetopt_print_help(const NVGetoptOption *options, * prepend the single character version of the option, * possibly with an argument; e.g., "-f" or "-f BAR" */ - if (isalpha(o->val)) { + if (o->val <= UCHAR_MAX && o->val >= 0 && isalpha(o->val)) { char scratch[16]; char *tmp; snprintf(scratch, sizeof(scratch), "%c", o->val); diff --git a/multiple_screens.c b/multiple_screens.c index 143ffd5..89aaffd 100644 --- a/multiple_screens.c +++ b/multiple_screens.c @@ -781,10 +781,9 @@ static void create_adjacencies(Options *op, XConfigPtr config, XConfigLayoutPtr layout) { XConfigAdjacencyPtr adj, prev_adj; - XConfigScreenPtr screen, prev; + XConfigScreenPtr screen; int i; - - prev = NULL; + i = 0; prev_adj = NULL; @@ -803,7 +802,6 @@ static void create_adjacencies(Options *op, XConfigPtr config, } prev_adj = adj; - prev = screen; i++; } diff --git a/nvidia-xconfig.h b/nvidia-xconfig.h index 01521da..65168de 100644 --- a/nvidia-xconfig.h +++ b/nvidia-xconfig.h @@ -201,8 +201,6 @@ int copy_file(const char *srcfile, const char *dstfile, mode_t mode); int directory_exists(const char *dir); -char *fget_next_line(FILE *fp, int *eof); - /* make_usable.c */ int update_modules(XConfigPtr config); diff --git a/option_table.h b/option_table.h index 4089f15..5ddfaeb 100644 --- a/option_table.h +++ b/option_table.h @@ -12,54 +12,55 @@ #include "nvidia-xconfig.h" -#define SCREEN_OPTION 1 -#define LAYOUT_OPTION 2 -#define X_PREFIX_OPTION 3 -#define KEYBOARD_OPTION 5 -#define KEYBOARD_LIST_OPTION 6 -#define KEYBOARD_DRIVER_OPTION 7 -#define MOUSE_OPTION 8 -#define FORCE_GENERATE_OPTION 9 -#define MOUSE_LIST_OPTION 10 -#define MODE_OPTION 11 -#define MODE_LIST_OPTION 12 -#define REMOVE_MODE_OPTION 13 -#define NVIDIA_CFG_PATH_OPTION 14 -#define NVAGP_OPTION 15 -#define SLI_OPTION 16 -#define DISABLE_SCF_OPTION 17 -#define TRANSPARENT_INDEX_OPTION 18 -#define STEREO_OPTION 19 -#define ROTATE_OPTION 20 -#define QUERY_GPU_INFO_OPTION 21 -#define EXTRACT_EDIDS_OUTPUT_FILE_OPTION 22 -#define MULTI_GPU_OPTION 23 -#define NVIDIA_XINERAMA_INFO_ORDER_OPTION 24 -#define LOGO_PATH_OPTION 25 -#define METAMODE_ORIENTATION_OPTION 26 -#define VIRTUAL_OPTION 27 -#define USE_DISPLAY_DEVICE_OPTION 28 -#define CUSTOM_EDID_OPTION 29 -#define TV_STANDARD_OPTION 30 -#define TV_OUT_FORMAT_OPTION 31 -#define TV_OVER_SCAN_OPTION 32 -#define COOL_BITS_OPTION 33 -#define ACPID_SOCKET_PATH_OPTION 34 -#define HANDLE_SPECIAL_KEYS_OPTION 35 -#define PRESERVE_DRIVER_NAME_OPTION 36 -#define CONNECTED_MONITOR_OPTION 37 -#define REGISTRY_DWORDS_OPTION 38 -#define META_MODES_OPTION 39 -#define COLOR_SPACE_OPTION 40 -#define COLOR_RANGE_OPTION 41 -#define BUSID_OPTION 42 -#define DEVICE_OPTION 43 -#define FLATPANEL_PROPERTIES_OPTION 44 -#define NVIDIA_3DVISION_USB_PATH_OPTION 45 -#define NVIDIA_3DVISIONPRO_CONFIG_FILE_OPTION 46 -#define NVIDIA_3DVISION_DISPLAY_TYPE_OPTION 47 -/* skip 48-57, as these are '0' - '9' */ -#define RESTORE_ORIGINAL_BACKUP_OPTION 58 +enum { + SCREEN_OPTION = 1024, + LAYOUT_OPTION, + X_PREFIX_OPTION, + KEYBOARD_OPTION, + KEYBOARD_LIST_OPTION, + KEYBOARD_DRIVER_OPTION, + MOUSE_OPTION, + FORCE_GENERATE_OPTION, + MOUSE_LIST_OPTION, + MODE_OPTION, + MODE_LIST_OPTION, + REMOVE_MODE_OPTION, + NVIDIA_CFG_PATH_OPTION, + NVAGP_OPTION, + SLI_OPTION, + DISABLE_SCF_OPTION, + TRANSPARENT_INDEX_OPTION, + STEREO_OPTION, + ROTATE_OPTION, + QUERY_GPU_INFO_OPTION, + EXTRACT_EDIDS_OUTPUT_FILE_OPTION, + MULTI_GPU_OPTION, + NVIDIA_XINERAMA_INFO_ORDER_OPTION, + LOGO_PATH_OPTION, + METAMODE_ORIENTATION_OPTION, + VIRTUAL_OPTION, + USE_DISPLAY_DEVICE_OPTION, + CUSTOM_EDID_OPTION, + TV_STANDARD_OPTION, + TV_OUT_FORMAT_OPTION, + TV_OVER_SCAN_OPTION, + COOL_BITS_OPTION, + ACPID_SOCKET_PATH_OPTION, + HANDLE_SPECIAL_KEYS_OPTION, + PRESERVE_DRIVER_NAME_OPTION, + CONNECTED_MONITOR_OPTION, + REGISTRY_DWORDS_OPTION, + META_MODES_OPTION, + COLOR_SPACE_OPTION, + COLOR_RANGE_OPTION, + BUSID_OPTION, + DEVICE_OPTION, + FLATPANEL_PROPERTIES_OPTION, + NVIDIA_3DVISION_USB_PATH_OPTION, + NVIDIA_3DVISIONPRO_CONFIG_FILE_OPTION, + NVIDIA_3DVISION_DISPLAY_TYPE_OPTION, + RESTORE_ORIGINAL_BACKUP_OPTION, +}; /* * To add a boolean option to nvidia-xconfig: @@ -187,57 +187,3 @@ void xconfigPrint(MsgType t, const char *msg) if (newline) fmt(stream, NULL, ""); } /* xconfigPrint */ - - -/* - * fget_next_line() - read from the given FILE stream until a newline, - * EOF, or null terminator is encountered, writing data into a - * growable buffer. The eof parameter is set to TRUE when EOF is - * encountered. In all cases, the returned string is null-terminated. - * - * XXX this function will be rather slow because it uses fgetc() to - * pull each character off the stream one at a time; this is done so - * that each character can be examined as it's read so that we can - * appropriately deal with EOFs and newlines. A better implementation - * would use fgets(), but that would still require us to parse each - * read line, checking for newlines or guessing if we hit an EOF. - */ - -#define NV_LINE_LEN 32 - -char *fget_next_line(FILE *fp, int *eof) -{ - char *buf = NULL, *tmpbuf; - char *c = NULL; - int len = 0, buflen = 0; - - if (eof) *eof = FALSE; - - while (1) { - if (buflen == len) { /* buffer isn't big enough -- grow it */ - buflen += NV_LINE_LEN; - tmpbuf = (char *) nvalloc (buflen); - if (buf) { - memcpy (tmpbuf, buf, len); - free (buf); - } - buf = tmpbuf; - c = buf + len; - } - - *c = fgetc(fp); - - if ((*c == EOF) && (eof)) *eof = TRUE; - if ((*c == EOF) || (*c == '\n') || (*c == '\0')) { - *c = '\0'; - return buf; - } - - len++; - c++; - - } /* while (1) */ - - return NULL; /* should never get here */ - -} /* fget_next_line() */ @@ -65,6 +65,7 @@ WHOAMI ?= whoami HOSTNAME_CMD ?= hostname DATE ?= date GZIP_CMD ?= gzip +CHMOD ?= chmod NV_AUTO_DEPEND ?= 1 NV_VERBOSE ?= 0 @@ -156,6 +157,25 @@ ifndef NVIDIA_VERSION $(error NVIDIA_VERSION undefined) endif + +############################################################################## +# Several of the functions below take an argument that indicates if +# the expression is for the target platform (the system the built +# program is going to run on) or the host platform (the system +# performing the build). The argument is either "HOST" or "TARGET" +# and needs to be converted: +# +# "HOST" -> "HOST_" +# "TARGET" -> "" +# +# and prepended to "CC" or "CFLAGS" +############################################################################## + +host_target = $(patsubst HOST,HOST_,$(patsubst TARGET,,$(1))) +host_target_cc = $(call host_target,$(1))CC +host_target_cflags = $(call host_target,$(1))CFLAGS + + ############################################################################## # to generate the dependency files, use the compiler's "-MM" option to # generate output of the form "foo.o : foo.c foo.h"; then, use sed to @@ -168,13 +188,14 @@ endif # applies to the object files produced in the build. # # Arguments: -# $(1): CC command (CC or HOST_CC) +# $(1): whether for host or target platform ("HOST" or "TARGET") # $(2): source filename # $(3): object filename ############################################################################## ifeq ($(NV_AUTO_DEPEND),1) - AUTO_DEP_CMD = && $($(1)) -MM $$(CFLAGS) $$< | $$(SED) \ + AUTO_DEP_CMD = && $($(call host_target_cc,$(1))) \ + -MM $$($(call host_target_cflags,$(1))) $$< | $$(SED) \ -e "s,: ,: $$$$\(wildcard ," \ -e "s,\([^\\]\)$$$$,\1)," \ -e "s;^$$(addsuffix .o,$$(notdir $$(basename $(2)))): ;$(3): ;" \ @@ -249,11 +270,12 @@ BUILD_DEPENDENCY_LIST = \ ############################################################################## # functions to define a rule to build an object file; the first -# argument is either CC or HOST_CC, the second argument is the source -# file to compile, and the third argument (_WITH_OBJECT_NAME-only) is -# the object filename to produce. Example usage: +# argument whether the rule is for the target or host platform ("HOST" +# or "TARGET"), the second argument is the source file to compile, and +# the third argument (_WITH_OBJECT_NAME-only) is the object filename +# to produce. Example usage: # -# $(eval $(call DEFINE_OBJECT_RULE,CC,foo.c)) +# $(eval $(call DEFINE_OBJECT_RULE,TARGET,foo.c)) # # Note this also attempts to include the dependency file for this # source file. @@ -266,7 +288,8 @@ BUILD_DEPENDENCY_LIST = \ define DEFINE_OBJECT_RULE_WITH_OBJECT_NAME $(3): $(2) @$(MKDIR) $(OUTPUTDIR) - $$(call quiet_cmd,$(1)) $$(CFLAGS) -c $$< -o $$@ \ + $$(call quiet_cmd,$(call host_target_cc,$(1))) \ + $$($(call host_target_cflags,$(1))) -c $$< -o $$@ \ $(call AUTO_DEP_CMD,$(1),$(2),$(3)) -include $$(call BUILD_DEPENDENCY_LIST,$(3)) @@ -1 +1 @@ -NVIDIA_VERSION = 302.17 +NVIDIA_VERSION = 304.22 |