瀏覽代碼

Rename __stdio_close_all to __stdio_flush_buffers. Eliminate an
unnecessary variable

Eric Andersen 24 年之前
父節點
當前提交
a7941d4f37
共有 4 個文件被更改,包括 15 次插入21 次删除
  1. 4 6
      libc/misc/internals/__uClibc_main.c
  2. 2 2
      libc/stdio/stdio.c
  3. 4 6
      libc/stdlib/abort.c
  4. 5 7
      libc/stdlib/atexit.c

+ 4 - 6
libc/misc/internals/__uClibc_main.c

@@ -28,16 +28,14 @@ void __uClibc_main(int argc, char **argv, char **envp)
 #ifdef HAVE_ELF
 weak_alias(__environ, environ);
 extern void weak_function __init_stdio(void);
-extern void weak_function __stdio_close_all(void);
+extern void weak_function __stdio_flush_buffers(void);
 extern void weak_function __pthread_initialize_minimal (void);
 #else
 extern void __init_stdio(void);
-extern void __stdio_close_all(void);
+extern void __stdio_flush_buffers(void);
 extern void __pthread_initialize_minimal (void);
 #endif	
 
-typedef void (*vfuncp) (void);
-vfuncp __uClibc_cleanup = __stdio_close_all;
 
 /*
  * Now for our main routine.
@@ -95,7 +93,7 @@ char **__environ = 0;
 /*
  * Define an empty function and use it as a weak alias for the stdio
  * initialization routine.  That way we don't pull in all the stdio
- * code unless we need to.  Similarly, do the same for __stdio_close_all
+ * code unless we need to.  Similarly, do the same for __stdio_flush_buffers
  * so as not to include atexit unnecessarily.
  *
  * NOTE!!! This is only true for the _static_ case!!!
@@ -107,6 +105,6 @@ void __uClibc_empty_func(void)
 {
 }
 weak_alias(__uClibc_empty_func, __init_stdio);
-weak_alias(__uClibc_empty_func, __stdio_close_all);
+weak_alias(__uClibc_empty_func, __stdio_flush_buffers);
 #endif
 #endif	

+ 2 - 2
libc/stdio/stdio.c

@@ -193,10 +193,10 @@ FILE *_free_file_list = 0;
 char _free_buffer_index = FIXED_BUFFERS;
 
 /*
- * __stdio_close_all is automatically when exiting if stdio is used.
+ * __stdio_flush_buffers is automatically when exiting if stdio is used.
  * See misc/internals/__uClibc_main.c and and stdlib/atexit.c.
  */
-void __stdio_close_all(void)
+void __stdio_flush_buffers(void)
 {
 	fflush(NULL);				/* Files will be closed on _exit call. */
 }

+ 4 - 6
libc/stdlib/abort.c

@@ -46,8 +46,7 @@ Cambridge, MA 02139, USA.  */
 #define ABORT_INSTRUCTION
 #endif
 
-typedef void (*vfuncp) (void);
-extern vfuncp __uClibc_cleanup;
+extern void __stdio_flush_buffers(void);
 extern void _exit __P((int __status)) __attribute__ ((__noreturn__));
 static int been_there_done_that = 0;
 
@@ -61,10 +60,9 @@ void abort(void)
 	sigprocmask(SIG_UNBLOCK, &sigset, (sigset_t *) NULL);
     }
 
-    /* __uClibc_cleanup NULLs itself out after being called */
-    if (__uClibc_cleanup) {		
-	__uClibc_cleanup();
-    }
+    /* If we are using stdio, flush all open streams */
+    if (__stdio_flush_buffers)
+	__stdio_flush_buffers();
 
     while (1) {
 	/* Try to suicide with a SIGABRT.  */

+ 5 - 7
libc/stdlib/atexit.c

@@ -17,7 +17,7 @@
  *   Changed name of __cleanup to __uClibc_cleanup.
  *   Moved declaration of __uClibc_cleanup to __uClibc_main
  *      where it is initialized with (possibly weak alias)
- *      __stdio_close_all.
+ *      __stdio_flush_buffers.
  *
  * Jul 2001          Steve Thayer
  * 
@@ -44,7 +44,7 @@ typedef enum {
 	ef_on_exit
 } ef_type; /* exit function types */
 
-extern void __stdio_close_all(void);
+extern void __stdio_flush_buffers(void);
 
 /* this is in the L_exit object */
 extern void (*__exit_cleanup) (int);
@@ -139,13 +139,11 @@ void __exit_handler(int status)
 			break;
 		}
 	}
-	if (__stdio_close_all)
-	  __stdio_close_all();
 }
 #endif
 
 #ifdef L_exit
-extern void (*__uClibc_cleanup) (void);
+extern void __stdio_flush_buffers(void);
 void (*__exit_cleanup) (int) = 0;
 
 /*
@@ -159,8 +157,8 @@ void exit(int rv)
 	}
 
 	/* Clean up everything else */
-	if (__uClibc_cleanup) 
-	    __uClibc_cleanup();
+	if (__stdio_flush_buffers) 
+	    __stdio_flush_buffers();
 
 	_exit(rv);
 }