浏览代码

Remove vestigial locking init from sprintf routines.

Denis Vlasenko 17 年之前
父节点
当前提交
023509e8e5
共有 3 个文件被更改,包括 3 次插入12 次删除
  1. 2 0
      libc/stdio/vdprintf.c
  2. 1 8
      libc/stdio/vsnprintf.c
  3. 0 4
      libc/stdio/vswprintf.c

+ 2 - 0
libc/stdio/vdprintf.c

@@ -47,6 +47,8 @@ int vdprintf(int filedes, const char * __restrict format, va_list arg)
 	__INIT_MBSTATE(&(f.__state));
 	__INIT_MBSTATE(&(f.__state));
 #endif /* __STDIO_MBSTATE */
 #endif /* __STDIO_MBSTATE */
 
 
+/* _vfprintf_internal doesn't do any locking, locking init is here
+ * only because of fflush_unlocked. TODO? */
 #ifdef __UCLIBC_HAS_THREADS__
 #ifdef __UCLIBC_HAS_THREADS__
 	f.__user_locking = 1;		/* Set user locking. */
 	f.__user_locking = 1;		/* Set user locking. */
 	__stdio_init_mutex(&f.__lock);
 	__stdio_init_mutex(&f.__lock);

+ 1 - 8
libc/stdio/vsnprintf.c

@@ -41,16 +41,13 @@ int vsnprintf(char *__restrict buf, size_t size,
 	__INIT_MBSTATE(&(f.__state));
 	__INIT_MBSTATE(&(f.__state));
 #endif /* __STDIO_MBSTATE */
 #endif /* __STDIO_MBSTATE */
 
 
-#ifdef __UCLIBC_HAS_THREADS__
-	f.__user_locking = 1;		/* Set user locking. */
-	__stdio_init_mutex(&f.__lock);
-#endif
 	f.__nextopen = NULL;
 	f.__nextopen = NULL;
 
 
 	if (size > SIZE_MAX - (size_t) buf) {
 	if (size > SIZE_MAX - (size_t) buf) {
 		size = SIZE_MAX - (size_t) buf;
 		size = SIZE_MAX - (size_t) buf;
 	}
 	}
 
 
+/* TODO: this comment seems to be wrong */
 	/* Set these last since __bufputc initialization depends on
 	/* Set these last since __bufputc initialization depends on
 	 * __user_locking and only gets set if user locking is on. */
 	 * __user_locking and only gets set if user locking is on. */
 	f.__bufstart = (unsigned char *) buf;
 	f.__bufstart = (unsigned char *) buf;
@@ -195,10 +192,6 @@ int vsnprintf(char *__restrict buf, size_t size,
 	__INIT_MBSTATE(&(f.__state));
 	__INIT_MBSTATE(&(f.__state));
 #endif /* __STDIO_MBSTATE */
 #endif /* __STDIO_MBSTATE */
 
 
-#ifdef __UCLIBC_HAS_THREADS__
-	f.__user_locking = 1;		/* Set user locking. */
-	__stdio_init_mutex(&f.__lock);
-#endif
 	f.__nextopen = NULL;
 	f.__nextopen = NULL;
 
 
 	rv = _vfprintf_internal(&f, format, arg);
 	rv = _vfprintf_internal(&f, format, arg);

+ 0 - 4
libc/stdio/vswprintf.c

@@ -38,10 +38,6 @@ int vswprintf(wchar_t *__restrict buf, size_t size,
 	__INIT_MBSTATE(&(f.__state));
 	__INIT_MBSTATE(&(f.__state));
 #endif /* __STDIO_MBSTATE */
 #endif /* __STDIO_MBSTATE */
 
 
-#ifdef __UCLIBC_HAS_THREADS__
-	f.__user_locking = 1;		/* Set user locking. */
-	__stdio_init_mutex(&f.__lock);
-#endif
 	f.__nextopen = NULL;
 	f.__nextopen = NULL;
 
 
 	if (size > ((SIZE_MAX - (size_t) buf)/sizeof(wchar_t))) {
 	if (size > ((SIZE_MAX - (size_t) buf)/sizeof(wchar_t))) {