From 0165fe128339733822cf56c6d230de4778bbad39 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sun, 29 Apr 2018 19:01:28 +0200 Subject: Codechange: remove endian_check in favour of __BYTE_ORDER macro (Rubidium) (#6762) --- Makefile.lang.in | 26 ++++------------ Makefile.setting.in | 19 ++---------- Makefile.src.in | 25 +++------------- config.lib | 27 ----------------- configure | 1 - src/core/endian_type.hpp | 8 ++--- src/endian_check.cpp | 78 ------------------------------------------------ 7 files changed, 16 insertions(+), 168 deletions(-) delete mode 100644 src/endian_check.cpp diff --git a/Makefile.lang.in b/Makefile.lang.in index fbed06b79..7ce331913 100644 --- a/Makefile.lang.in +++ b/Makefile.lang.in @@ -6,7 +6,6 @@ # See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . STRGEN = !!STRGEN!! -ENDIAN_CHECK = !!ENDIAN_CHECK!! SRC_DIR = !!SRC_DIR!! LANG_DIR = !!LANG_DIR!! BIN_DIR = !!BIN_DIR!! @@ -25,11 +24,6 @@ ifeq ($(LANG_SUPPRESS), yes) LANG_ERRORS = >/dev/null 2>&1 endif -# Make sure endian_host.h is reachable as if it was in the src/ dir -CFLAGS_BUILD += -I $(LANG_OBJS_DIR) - -ENDIAN_TARGETS := endian_host.h endian_target.h $(ENDIAN_CHECK) - # Check if we want to show what we are doing ifdef VERBOSE Q = @@ -43,19 +37,19 @@ RES := $(shell mkdir -p $(BIN_DIR)/lang ) all: table/strings.h $(LANGS) -strgen_base.o: $(SRC_DIR)/strgen/strgen_base.cpp $(SRC_DIR)/strgen/strgen.h endian_host.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h $(SRC_DIR)/safeguards.h +strgen_base.o: $(SRC_DIR)/strgen/strgen_base.cpp $(SRC_DIR)/strgen/strgen.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h $(SRC_DIR)/safeguards.h $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $< -strgen.o: $(SRC_DIR)/strgen/strgen.cpp $(SRC_DIR)/strgen/strgen.h endian_host.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h $(SRC_DIR)/safeguards.h +strgen.o: $(SRC_DIR)/strgen/strgen.cpp $(SRC_DIR)/strgen/strgen.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h $(SRC_DIR)/safeguards.h $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $< -string.o: $(SRC_DIR)/string.cpp endian_host.h $(SRC_DIR)/safeguards.h +string.o: $(SRC_DIR)/string.cpp $(SRC_DIR)/safeguards.h $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $< -alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp endian_host.h $(SRC_DIR)/safeguards.h +alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp $(SRC_DIR)/safeguards.h $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $< @@ -80,21 +74,11 @@ $(LANGS): %.lng: $(LANG_DIR)/%.txt $(STRGEN) lang/english.txt $(E) '$(STAGE) Compiling language $(*F)' $(Q)./$(STRGEN) $(STRGEN_FLAGS) -s $(LANG_DIR) -d $(LANG_OBJS_DIR) $< $(LANG_ERRORS) && cp $@ $(BIN_DIR)/lang || true # Do not fail all languages when one fails -# The targets to compile the endian-code - -endian_host.h: $(ENDIAN_CHECK) - $(E) '$(STAGE) Testing endianness for host' - $(Q)./$(ENDIAN_CHECK) > $@ - -$(ENDIAN_CHECK): $(SRC_DIR)/endian_check.cpp - $(E) '$(STAGE) Compiling and Linking $@' - $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) $< -o $@ - depend: clean: $(E) '$(STAGE) Cleaning up language files' - $(Q)rm -f strgen.o string.o alloc_func.o getoptdata.o table/strings.h $(STRGEN) $(LANGS) $(LANGS:%=$(BIN_DIR)/lang/%) lang/english.* $(ENDIAN_TARGETS) + $(Q)rm -f strgen.o string.o alloc_func.o getoptdata.o table/strings.h $(STRGEN) $(LANGS) $(LANGS:%=$(BIN_DIR)/lang/%) lang/english.* mrproper: clean $(Q)rm -rf $(BIN_DIR)/lang diff --git a/Makefile.setting.in b/Makefile.setting.in index d89501d21..656de0572 100644 --- a/Makefile.setting.in +++ b/Makefile.setting.in @@ -6,7 +6,6 @@ # See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . SETTINGSGEN = !!SETTINGSGEN!! -ENDIAN_CHECK = !!ENDIAN_CHECK!! SRC_DIR = !!SRC_DIR!! CXX_BUILD = !!CXX_BUILD!! CFLAGS_BUILD = !!CFLAGS_BUILD!! @@ -15,8 +14,6 @@ LDFLAGS_BUILD = !!LDFLAGS_BUILD!! STAGE = !!STAGE!! SETTING_OBJS_DIR = !!SETTING_OBJS_DIR!! -ENDIAN_TARGETS := endian_host.h endian_target.h $(ENDIAN_CHECK) - # Check if we want to show what we are doing ifdef VERBOSE Q = @@ -32,7 +29,7 @@ settingsgen.o: $(SRC_DIR)/settingsgen/settingsgen.cpp $(SRC_DIR)/string_func.h $ $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $< -alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp endian_host.h $(SRC_DIR)/safeguards.h +alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp $(SRC_DIR)/safeguards.h $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $< @@ -40,7 +37,7 @@ getoptdata.o: $(SRC_DIR)/misc/getoptdata.cpp $(SRC_DIR)/misc/getoptdata.h $(SRC_ $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)' $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $< -string.o: $(SRC_DIR)/string.cpp endian_host.h $(SRC_DIR)/safeguards.h +string.o: $(SRC_DIR)/string.cpp $(SRC_DIR)/safeguards.h $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $< @@ -57,21 +54,11 @@ table/settings.h: $(SETTINGSGEN) $(SRC_DIR)/table/settings.h.preamble $(SRC_DIR) @mkdir -p table $(Q)./$(SETTINGSGEN) -o table/settings.h -b $(SRC_DIR)/table/settings.h.preamble -a $(SRC_DIR)/table/settings.h.postamble $(SRC_DIR)/table/*.ini -# The targets to compile the endian-code - -endian_host.h: $(ENDIAN_CHECK) - $(E) '$(STAGE) Testing endianness for host' - $(Q)./$(ENDIAN_CHECK) > $@ - -$(ENDIAN_CHECK): $(SRC_DIR)/endian_check.cpp - $(E) '$(STAGE) Compiling and Linking $@' - $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) $< -o $@ - depend: clean: $(E) '$(STAGE) Cleaning up settings files' - $(Q)rm -f settingsgen.o alloc_func.o getoptdata.o ini_load.o $(SETTINGSGEN) $(ENDIAN_TARGETS) table/settings.h + $(Q)rm -f settingsgen.o alloc_func.o getoptdata.o ini_load.o $(SETTINGSGEN) table/settings.h mrproper: clean diff --git a/Makefile.src.in b/Makefile.src.in index 21e93a5e2..0589ba69a 100644 --- a/Makefile.src.in +++ b/Makefile.src.in @@ -29,9 +29,7 @@ SCRIPT_SRC_DIR = !!SCRIPT_SRC_DIR!! MEDIA_DIR = !!MEDIA_DIR!! TTD = !!TTD!! STRGEN = !!STRGEN!! -ENDIAN_CHECK = !!ENDIAN_CHECK!! DEPEND = !!DEPEND!! -ENDIAN_FORCE = !!ENDIAN_FORCE!! OS = !!OS!! STAGE = !!STAGE!! MAKEDEPEND = !!MAKEDEPEND!! @@ -40,7 +38,6 @@ SORT = !!SORT!! AWK = !!AWK!! CONFIG_CACHE_COMPILER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_COMPILER!! CONFIG_CACHE_LINKER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_LINKER!! -CONFIG_CACHE_ENDIAN = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_ENDIAN!! CONFIG_CACHE_SOURCE = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_SOURCE!! CONFIG_CACHE_VERSION = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_VERSION!! @@ -52,19 +49,16 @@ OBJS := $(OBJS_C) $(OBJS_CPP) $(OBJS_MM) $(OBJS_RC) SRCS := !!SRCS!! # All C-files depend on those 3 files -FILE_DEP := $(CONFIG_CACHE_COMPILER) endian_target.h +FILE_DEP := $(CONFIG_CACHE_COMPILER) # Create all dirs and subdirs RES := $(shell mkdir -p $(BIN_DIR) $(sort $(dir $(OBJS)))) -# Make sure endian_target.h is reasable as if it was in the src/ dir CFLAGS += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) -I $(SETTING_OBJS_DIR) CFLAGS_MAKEDEP += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) -I $(SETTING_OBJS_DIR) ifdef SCRIPT_SRC_DIR CFLAGS_MAKEDEP += -I $(SCRIPT_SRC_DIR) endif -ENDIAN_TARGETS := endian_target.h $(ENDIAN_CHECK) - # Check if we want to show what we are doing ifdef VERBOSE Q = @@ -108,7 +102,6 @@ endif # This helps to recompile if flags change RES := $(shell if [ "`cat $(CONFIG_CACHE_COMPILER) 2>/dev/null`" != "$(CFLAGS) $(CXXFLAGS)" ]; then echo "$(CFLAGS) $(CXXFLAGS)" > $(CONFIG_CACHE_COMPILER); fi ) RES := $(shell if [ "`cat $(CONFIG_CACHE_LINKER) 2>/dev/null`" != "$(LDFLAGS) $(LIBS)" ]; then echo "$(LDFLAGS) $(LIBS)" > $(CONFIG_CACHE_LINKER); fi ) -RES := $(shell if [ "`cat $(CONFIG_CACHE_ENDIAN) 2>/dev/null`" != "$(ENDIAN_FORCE)" ]; then echo "$(ENDIAN_FORCE)" > $(CONFIG_CACHE_ENDIAN); fi ) # If there is a change in the source-file-list, make sure we recheck the deps RES := $(shell if [ "`cat $(CONFIG_CACHE_SOURCE) 2>/dev/null`" != "$(SRCS)" ]; then echo "$(SRCS)" > $(CONFIG_CACHE_SOURCE); fi ) @@ -121,7 +114,7 @@ DEP_MASK := %.d DEPS := $(OBJS:%.o=%.d) # Only include the deps if we are compiling everything -ifeq ($(filter $(ENDIAN_TARGETS) %.o clean mrproper, $(MAKECMDGOALS)),) +ifeq ($(filter %.o clean mrproper, $(MAKECMDGOALS)),) -include $(DEPS) else # In case we want to compile a single target, include the .d file for it @@ -155,7 +148,7 @@ DEP_MASK := DEPS := Makefile.dep # Only include the deps if we are not cleaning -ifeq ($(filter $(ENDIAN_TARGETS) depend clean mrproper, $(MAKECMDGOALS)),) +ifeq ($(filter depend clean mrproper, $(MAKECMDGOALS)),) -include Makefile.dep endif @@ -273,16 +266,6 @@ ifeq ($(OS), DOS) $(Q)$(ROOT_DIR)/os/dos/make_dos_binary_selfcontained.sh $(SRC_OBJS_DIR)/$@ endif -# The targets to compile the endian-code - -endian_target.h: $(ENDIAN_CHECK) $(CONFIG_CACHE_ENDIAN) - $(E) '$(STAGE) Testing endianness for target' - $(Q)./$(ENDIAN_CHECK) $(ENDIAN_FORCE) > $@ - -$(ENDIAN_CHECK): $(SRC_DIR)/endian_check.cpp - $(E) '$(STAGE) Compiling and Linking $@' - $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) $< -o $@ - # Revision files $(SRC_DIR)/rev.cpp: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/rev.cpp.in @@ -297,7 +280,7 @@ depend: $(DEPS) clean: $(E) '$(STAGE) Cleaning up object files' - $(Q)rm -f $(DEPS) $(OBJS) $(TTD) $(DEPEND) $(TTD:%=$(BIN_DIR)/%) $(BIN_DIR)/baseset/openttd.32.bmp $(CONFIG_CACHE_COMPILER) $(CONFIG_CACHE_LINKER) $(CONFIG_CACHE_ENDIAN) $(CONFIG_CACHE_SOURCE) $(ENDIAN_TARGETS) + $(Q)rm -f $(DEPS) $(OBJS) $(TTD) $(DEPEND) $(TTD:%=$(BIN_DIR)/%) $(BIN_DIR)/baseset/openttd.32.bmp $(CONFIG_CACHE_COMPILER) $(CONFIG_CACHE_LINKER) $(CONFIG_CACHE_SOURCE) mrproper: clean $(Q)rm -f $(SRC_DIR)/rev.cpp $(SRC_DIR)/os/windows/ottdres.rc diff --git a/config.lib b/config.lib index c54a7a712..7fa44f5b3 100644 --- a/config.lib +++ b/config.lib @@ -31,7 +31,6 @@ set_default() { awk="awk" pkg_config="pkg-config" os="DETECT" - endian="AUTO" cpu_type="DETECT" config_log="config.log" prefix_dir="/usr/local" @@ -108,7 +107,6 @@ set_default() { awk pkg_config os - endian cpu_type config_log prefix_dir @@ -222,9 +220,6 @@ detect_params() { --lipo) prev_p="lipo";; --lipo=*) lipo="$optarg";; - --endian) prev_p="endian";; - --endian=*) endian="$optarg";; - # Alias --prefix with --prefix-dir, for compatibility with GNU autotools @@ -531,7 +526,6 @@ check_params() { # Some params want to be in full uppercase, else they might not work as # expected.. fix that here - endian=`echo $endian | tr '[a-z]' '[A-Z]'` os=`echo $os | tr '[a-z]' '[A-Z]'` cpu_type=`echo $cpu_type | tr '[a-z]' '[A-Z]'` @@ -547,17 +541,6 @@ check_params() { # Check if all params have valid values - # Endian only allows AUTO, LE and, BE - if [ -z "`echo $endian | egrep '^(AUTO|LE|BE|PREPROCESSOR)$'`" ]; then - log 1 "configure: error: invalid option --endian=$endian" - log 1 " Available options are: --endian=[AUTO|LE|BE]" - exit 1 - fi - if [ "$endian" = "PREPROCESSOR" ] && [ "$os" != "OSX" ]; then - log 1 "configure: error: invalid option --endian=$endian" - log 1 " PREPROCESSOR is only available for OSX" - exit 1 - fi # OS only allows DETECT, UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, MORPHOS, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, and DOS if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|DRAGONFLY|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS)$'`" ]; then log 1 "configure: error: invalid option --os=$os" @@ -890,12 +873,6 @@ check_params() { detect_sort - if [ "$os" = "OSX" ] && [ "$endian" = "AUTO" ]; then - endian="PREPROCESSOR" - fi - - log 1 "checking endianness... $endian" - # Suppress language errors when there is a version defined, indicating a release # It just isn't pretty if any release produces warnings in the languages. if [ -f "$ROOT_DIR/version" ]; then @@ -3161,17 +3138,14 @@ make_sed() { s@!!INSTALL_DIR!!@$install_dir@g; s@!!BINARY_NAME!!@$binary_name@g; s@!!STRGEN!!@$STRGEN@g; - s@!!ENDIAN_CHECK!!@$ENDIAN_CHECK@g; s@!!DEPEND!!@$DEPEND@g; s@!!SETTINGSGEN!!@$SETTINGSGEN@g; - s@!!ENDIAN_FORCE!!@$endian@g; s@!!STAGE!!@$STAGE@g; s@!!MAKEDEPEND!!@$makedepend@g; s@!!CFLAGS_MAKEDEP!!@$cflags_makedep@g; s@!!SORT!!@$sort@g; s@!!CONFIG_CACHE_COMPILER!!@config.cache.compiler@g; s@!!CONFIG_CACHE_LINKER!!@config.cache.linker@g; - s@!!CONFIG_CACHE_ENDIAN!!@config.cache.endian@g; s@!!CONFIG_CACHE_SOURCE!!@config.cache.source@g; s@!!CONFIG_CACHE_VERSION!!@config.cache.version@g; s@!!CONFIG_CACHE_SOURCE_LIST!!@config.cache.source.list@g; @@ -3406,7 +3380,6 @@ showhelp() { echo " DETECT/UNIX/OSX/FREEBSD/DRAGONFLY/OPENBSD/" echo " NETBSD/MORPHOS/HPUX/BEOS/SUNOS/CYGWIN/" echo " MINGW/OS2/DOS/HAIKU" - echo " --endian=ENDIAN set the endian of the HOST (AUTO/LE/BE)" echo "" echo "Paths:" echo " --prefix-dir=dir specifies the prefix for all installed" diff --git a/configure b/configure index 6cbe78946..7ca36480d 100755 --- a/configure +++ b/configure @@ -81,7 +81,6 @@ fi TTD="openttd$EXE" STRGEN="strgen$EXE" -ENDIAN_CHECK="endian_check$EXE" DEPEND="depend$EXE" SETTINGSGEN="settings_gen$EXE" diff --git a/src/core/endian_type.hpp b/src/core/endian_type.hpp index dbb7faec6..cb3e348b4 100644 --- a/src/core/endian_type.hpp +++ b/src/core/endian_type.hpp @@ -29,11 +29,11 @@ #if defined(WIN32) || defined(__OS2__) || defined(WIN64) #define TTD_ENDIAN TTD_LITTLE_ENDIAN #elif !defined(TESTING) - /* Else include endian[target/host].h, which has the endian-type, autodetected by the Makefile */ - #if defined(STRGEN) || defined(SETTINGSGEN) - #include "endian_host.h" + #include + #if __BYTE_ORDER == __LITTLE_ENDIAN + #define TTD_ENDIAN TTD_LITTLE_ENDIAN #else - #include "endian_target.h" + #define TTD_ENDIAN TTD_BIG_ENDIAN #endif #endif /* WIN32 || __OS2__ || WIN64 */ diff --git a/src/endian_check.cpp b/src/endian_check.cpp deleted file mode 100644 index 815e5abbe..000000000 --- a/src/endian_check.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* $Id$ */ - -/* - * This file is part of OpenTTD. - * OpenTTD 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, version 2. - * OpenTTD 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 OpenTTD. If not, see . - */ - -/** - * @file endian_check.cpp - * This pretty simple file checks if the system is LITTLE_ENDIAN or BIG_ENDIAN - * it does that by putting a 1 and a 0 in an array, and read it out as one - * number. If it is 1, it is LITTLE_ENDIAN, if it is 256, it is BIG_ENDIAN - * - * After that it outputs the contents of an include files (endian.h) - * that says or TTD_LITTLE_ENDIAN, or TTD_BIG_ENDIAN. Makefile takes - * care of the real writing to the file. - */ - -#include -#include - -/** Supported endian types */ -enum Endian { - ENDIAN_LITTLE, ///< little endian - ENDIAN_BIG, ///< big endian -}; - -/** - * Shortcut to printf("#define TTD_ENDIAN TTD_*_ENDIAN") - * @param endian endian type to define - */ -static inline void printf_endian(Endian endian) -{ - printf("#define TTD_ENDIAN %s\n", endian == ENDIAN_LITTLE ? "TTD_LITTLE_ENDIAN" : "TTD_BIG_ENDIAN"); -} - -/** - * Main call of the endian_check program - * @param argc argument count - * @param argv arguments themselves - * @return exit code - */ -int main (int argc, char *argv[]) -{ - unsigned char endian_test[2] = { 1, 0 }; - int force_BE = 0, force_LE = 0, force_PREPROCESSOR = 0; - - if (argc > 1 && strcmp(argv[1], "BE") == 0) force_BE = 1; - if (argc > 1 && strcmp(argv[1], "LE") == 0) force_LE = 1; - if (argc > 1 && strcmp(argv[1], "PREPROCESSOR") == 0) force_PREPROCESSOR = 1; - - printf("#ifndef ENDIAN_H\n#define ENDIAN_H\n"); - - if (force_LE == 1) { - printf_endian(ENDIAN_LITTLE); - } else if (force_BE == 1) { - printf_endian(ENDIAN_BIG); - } else if (force_PREPROCESSOR == 1) { - /* Support for universal binaries on OSX - * Universal binaries supports both PPC and x86 - * If a compiler for OSX gets this setting, it will always pick the correct endian and no test is needed - */ - printf("#ifdef __BIG_ENDIAN__\n"); - printf_endian(ENDIAN_BIG); - printf("#else\n"); - printf_endian(ENDIAN_LITTLE); - printf("#endif\n"); - } else if (*(short*)endian_test == 1 ) { - printf_endian(ENDIAN_LITTLE); - } else { - printf_endian(ENDIAN_BIG); - } - printf("#endif\n"); - - return 0; -} -- cgit v1.2.3-70-g09d2