diff options
author | davidxu <davidxu@FreeBSD.org> | 2005-04-02 01:20:00 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2005-04-02 01:20:00 +0000 |
commit | f066519e91e2290cb79ef12fe7c958ee462cda6c (patch) | |
tree | 6aaef5f553a6539306bd6f5679d039ed3c2abcce /lib/libthr/thread/thr_printf.c | |
parent | 3cc412b7837a105c757df856c422eb5f497bad67 (diff) | |
download | FreeBSD-src-f066519e91e2290cb79ef12fe7c958ee462cda6c.zip FreeBSD-src-f066519e91e2290cb79ef12fe7c958ee462cda6c.tar.gz |
Import my recent 1:1 threading working. some features improved includes:
1. fast simple type mutex.
2. __thread tls works.
3. asynchronous cancellation works ( using signal ).
4. thread synchronization is fully based on umtx, mainly, condition
variable and other synchronization objects were rewritten by using
umtx directly. those objects can be shared between processes via
shared memory, it has to change ABI which does not happen yet.
5. default stack size is increased to 1M on 32 bits platform, 2M for
64 bits platform.
As the result, some mysql super-smack benchmarks show performance is
improved massivly.
Okayed by: jeff, mtm, rwatson, scottl
Diffstat (limited to 'lib/libthr/thread/thr_printf.c')
-rw-r--r-- | lib/libthr/thread/thr_printf.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/lib/libthr/thread/thr_printf.c b/lib/libthr/thread/thr_printf.c index e6f1a84..7d32ae7 100644 --- a/lib/libthr/thread/thr_printf.c +++ b/lib/libthr/thread/thr_printf.c @@ -22,15 +22,10 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> #include <stdarg.h> #include <string.h> #include <unistd.h> @@ -57,15 +52,20 @@ _thread_printf(int fd, const char *fmt, ...) { static const char digits[16] = "0123456789abcdef"; va_list ap; - char buf[10]; + char buf[20]; char *s; - unsigned r, u; - int c, d; + unsigned long r, u; + int c; + long d; + int islong; va_start(ap, fmt); while ((c = *fmt++)) { + islong = 0; if (c == '%') { - c = *fmt++; +next: c = *fmt++; + if (c == '\0') + goto out; switch (c) { case 'c': pchar(fd, va_arg(ap, int)); @@ -73,20 +73,31 @@ _thread_printf(int fd, const char *fmt, ...) case 's': pstr(fd, va_arg(ap, char *)); continue; + case 'l': + islong = 1; + goto next; + case 'p': + islong = 1; case 'd': case 'u': - case 'p': case 'x': r = ((c == 'u') || (c == 'd')) ? 10 : 16; if (c == 'd') { - d = va_arg(ap, unsigned); + if (islong) + d = va_arg(ap, unsigned long); + else + d = va_arg(ap, unsigned); if (d < 0) { pchar(fd, '-'); - u = (unsigned)(d * -1); + u = (unsigned long)(d * -1); } else - u = (unsigned)d; - } else - u = va_arg(ap, unsigned); + u = (unsigned long)d; + } else { + if (islong) + u = va_arg(ap, unsigned long); + else + u = va_arg(ap, unsigned); + } s = buf; do { *s++ = digits[u % r]; @@ -98,6 +109,7 @@ _thread_printf(int fd, const char *fmt, ...) } pchar(fd, c); } +out: va_end(ap); } |