Summary: | Use _mesa wrappers for libc functions | ||
---|---|---|---|
Product: | Mesa | Reporter: | George - <fufutos610> |
Component: | Mesa core | Assignee: | mesa-dev |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | minor | ||
Priority: | high | ||
Version: | git | ||
Hardware: | x86 (IA32) | ||
OS: | Linux (All) | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: |
_mesa wrappers for libc functions
use _mesa wrappers for libc minor update: x86-64 similar to x86 update: wrap remaing calls Move system headers to imports.h Misc build fixes drop the headers move |
Description
George -
2005-09-15 09:00:51 UTC
Created attachment 3290 [details] [review] _mesa wrappers for libc functions Wrapping libc functions prevents the compiler from recognizing that they won't return (abort, exit, etc.), typechecking their arguments (fprintf, sprintf, etc.) or inlining them when it would be beneficial (sinf, memcpy, strlen, etc.) If anything, Mesa's existing wrappers should be removed in favor of using the C library functions directly. http://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Other-Builtins.html is a list of the C library functions that gcc will optimize, other compilers have similar lists. I've checked in the patch. Thanks. The wrappers are needed in order to build Mesa as an XFree86/X.org server module. For the functions which can be compiler built-ins (and aren't especially performance sensitive) there are preprocessor/macro wrappers (such as FABSF) which shouldn't prevent using the built-ins. Reopening to submit another patch: * Fix a few more calls: sprintf use wrapper strlen use wrapper strchr replace with strstr, is this ok ? atof replace with strtod, is this ok ? log add define exp add define ffs add wrapper bsearch add wrapper * Fix some libm calls which didn't use their defines * Remove two fprintf( stderr, ...) common_x86.c: changed to _mesa_debug t_vp_build.c: changed to _mesa_problem * Revert the change from vsprintf to _mesa_sprintf in slang_compile.c sorry for this Remaining calls: texenvprogram.o: U xf86exit t_vp_build.o: U xf86exit t_vertex_generic.o: U xf86abort slang_compile.o: U xf86exit U xf86vsprintf slang_execute.o: U xf86fclose U xf86fflush U xf86fopen U xf86fprintf xm_api.o: U xf86sscanf Created attachment 3301 [details] [review] use _mesa wrappers for libc Created attachment 3306 [details] [review] minor update: x86-64 similar to x86 Created attachment 3315 [details] [review] update: wrap remaing calls This is the last update for using wrappers. With this patch, the mesa core (libmesa.a) no longer has "external" symbols (when DEBUG is undefined) ! The patch fixes the remaining calls, as follows: fclose fflush fopen fprintf guard with DEBUG_XXX vsprintf add wrapper exit add wrapper abort replace with exit(1) It also moves some stuff out of glheader.h: move ffs stuff to imports.c move glcore.h to mtypes.h, imports.h glcore.h really doesn't belong in glheader.h, it defines the GLimports/GLexports mesa types move wgl stuff to dglwgl.h this is a *wild* guess based on grep, I just wanted to move this stuff out Btw, after the viewport changes indirect rendering segfaults in _swrast_clear_depth_buffer, if this helps ... I've checked in your latest patch. Thanks. I'll look into the _swrast_clear_depth_buffer() problem next. That should really be a separate bug report... (In reply to comment #8) > > I'll look into the _swrast_clear_depth_buffer() problem next. That should > really be a separate bug report... It is, bug 4087. Created attachment 3363 [details] [review] Move system headers to imports.h This patch moves system headers to imports.h * imports.h is a more appropriate place * remove FLT_MIN: it is in float.h which is included in all cases * remove _mesa_log2: does not exist * fix includes in s_tcc.c * fix includes in gen_matypes.c: this is stand-alone * fix includes in glapi/ Moreover in glheader.h, I replaced inttypes.h with stdint.h for DRI platforms. Both linux-dri and freebsd-dri configs use -std=c99, thus they should have this. I did this because including inttypes.h (from glheader.h) before stdlib.h (from imports.h) resulted in __SIZE_TYPE__ being undefined for drm.h. Using IN_DRI_DRIVER instead of platform checks allows makedepend to get this right as well. Created attachment 3364 [details] [review] Misc build fixes * src/mesa/Makefile: fix for depend (matypes.h) and osmesa target * src/mesa/drivers/dri/Makefile.template: cleanup after use of libdrm * math/m_debug, x86/: isolate the math debug code with DEBUG_MATH, RUN_DEBUG_BENCHMARK was actually implied by DEBUG (now DEBUG_MATH) in m_debug_util.h I've checked in the DEBUG_MATH changes, but not the other Makefile changes. src/mesa/Makefile can't have any 'ifeq/endif' lines because they're only suppoted in GNU-make. src/mesa/Makefile needs needs to work with conventional make on other systems. Created attachment 3547 [details] [review] drop the headers move I fixed the #includes in s_tcc.c and removed _mesa_log2() from imports.h I left in the FLT_MIN definition for now just to be safe. I'd have to test with XFree86/X.org to see whether or not it's still needed. FLT_MIN will probably go away after the accelerated indirect work, closing. Mass version move, cvs -> git |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.