Re: thinkpad mute mic key
I like this *MUCH* better than the way acpithinkpad volume buttons currently work. these buttons should be affecting the mixer, if at all possible, instead of doing things behind the audio system's back, which causes confusion. On Sun, Mar 13, 2011 at 10:11:54PM +0300, Alexander Polakov wrote: Hi, This is a diff to add support for mute microphone key, which can be found on some thinkpad models, which is currently reported as acpithinkpad0: unknown event 0x101b A simple solution would be just add definition to acpithinkpad.c and set handled to 1, but I chose a bit harder way of adding proper support. My attempt below. Index: sys/dev/audio.c === RCS file: /cvs/src/sys/dev/audio.c,v retrieving revision 1.111 diff -u -r1.111 audio.c --- sys/dev/audio.c 18 Nov 2010 21:15:14 - 1.111 +++ sys/dev/audio.c 13 Mar 2011 19:10:19 - @@ -244,7 +244,7 @@ #if NWSKBD 0 /* Mixer manipulation using keyboard */ -int wskbd_set_mixervolume(long); +int wskbd_set_mixervolume(long, int); #endif int @@ -3358,20 +3358,23 @@ #if NWSKBD 0 int -wskbd_set_mixervolume(long dir) +wskbd_set_mixervolume(long dir, int out) { struct audio_softc *sc; mixer_devinfo_t mi; int error; u_int gain; u_char balance, mute; + struct au_mixer_ports *ports; if (audio_cd.cd_ndevs == 0 || (sc = audio_cd.cd_devs[0]) == NULL) { DPRINTF((wskbd_set_mixervolume: audio_cd\n)); return (ENXIO); } - if (sc-sc_outports.master == -1) { + ports = out ? sc-sc_outports : sc-sc_inports; + + if (ports-master == -1) { DPRINTF((wskbd_set_mixervolume: master == -1\n)); return (ENXIO); } @@ -3379,7 +3382,7 @@ if (dir == 0) { /* Mute */ - error = au_get_mute(sc, sc-sc_outports, mute); + error = au_get_mute(sc, ports, mute); if (error != 0) { DPRINTF((wskbd_set_mixervolume: au_get_mute: %d\n, error)); @@ -3388,7 +3391,7 @@ mute = !mute; - error = au_set_mute(sc, sc-sc_outports, mute); + error = au_set_mute(sc, ports, mute); if (error != 0) { DPRINTF((wskbd_set_mixervolume: au_set_mute: %d\n, error)); @@ -3397,7 +3400,7 @@ } else { /* Raise or lower volume */ - mi.index = sc-sc_outports.master; + mi.index = ports-master; error = sc-hw_if-query_devinfo(sc-hw_hdl, mi); if (error != 0) { DPRINTF((wskbd_set_mixervolume: @@ -3405,14 +3408,14 @@ return (error); } - au_get_gain(sc, sc-sc_outports, gain, balance); + au_get_gain(sc, ports, gain, balance); if (dir 0) gain += mi.un.v.delta; else gain -= mi.un.v.delta; - error = au_set_gain(sc, sc-sc_outports, gain, balance); + error = au_set_gain(sc, ports, gain, balance); if (error != 0) { DPRINTF((wskbd_set_mixervolume: au_set_gain: %d\n, error)); Index: sys/dev/acpi/acpiasus.c === RCS file: /cvs/src/sys/dev/acpi/acpiasus.c,v retrieving revision 1.11 diff -u -r1.11 acpiasus.c --- sys/dev/acpi/acpiasus.c 28 Aug 2010 17:59:17 - 1.11 +++ sys/dev/acpi/acpiasus.c 13 Mar 2011 19:10:19 - @@ -90,7 +90,7 @@ int acpiasus_activate(struct device *, int); #if NAUDIO 0 NWSKBD 0 -extern int wskbd_set_mixervolume(long dir); +extern int wskbd_set_mixervolume(long dir, int out); #endif struct cfattach acpiasus_ca = { @@ -173,15 +173,15 @@ #if NAUDIO 0 NWSKBD 0 case ASUS_NOTIFY_VOLUMEMUTE: workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume, - (void *)(long)0, NULL); + (void *)(long)0, (void *)(int)1); break; case ASUS_NOTIFY_VOLUMEDOWN: workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume, - (void *)(long)-1, NULL); + (void *)(long)-1, (void *)(int)1); break; case ASUS_NOTIFY_VOLUMEUP: workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume, - (void *)(long)1, NULL); + (void *)(long)1, (void *)(int)1); break; #else case ASUS_NOTIFY_VOLUMEMUTE: Index: sys/dev/acpi/acpithinkpad.c === RCS file: /cvs/src/sys/dev/acpi/acpithinkpad.c,v retrieving revision 1.25 diff -u -r1.25 acpithinkpad.c ---
Re: wprintf and friends
On Sun, Mar 13, 2011 at 8:49 AM, Stefan Sperling s...@openbsd.org wrote: The vfwprintf.c innards are based on a mix of OpenBSD's vfprintf.c and NetBSD's vfwprintf.c. In NetBSD, both narrow and wide character versions are generated from the same file using tons of macro spaghetti. I didn't find that very readable, so I've taken the time to expand all the macros to their wide-character versions. This gives us a separate vfwprintf.c file which differs from vfprintf.c only where necessary. Below the actual diff (which mostly adds files) you'll find the diff between vfprintf.c and vfwprintf.c for convenience. The _SET_ORIENTATION() call in vswprintf.c should set the orientation to 1, not -1. (If you uncomment the //X lines in regress/lib/libc/orientation/orientation_test.c then it should catch this until you fix it.) Use FLOCKFILE/FUNLOCKFILE instead of flockfile/funlockfile in vfwprintf() This will probably need a libc bump when it does in which isn't included in this diff. Minor bump, yep. Philip Guenther
Re: bin/ksh: fix possible use of uninitialized variable
On Mon 2011.03.14 at 11:05 +0800, Kevin Lo wrote: This diff fixes uninitialized variable warnings emitted by gcc 4.2.1 on i386/amd64. How's this instead (lifted from mksh)? Index: eval.c === RCS file: /home/okan/hack/open/cvs/src/bin/ksh/eval.c,v retrieving revision 1.35 diff -u -p -r1.35 eval.c --- eval.c 24 Mar 2010 08:27:26 - 1.35 +++ eval.c 14 Mar 2011 07:09:37 - @@ -152,7 +152,10 @@ expand(char *cp, /* input word */ char *dp, *sp; /* dest., source */ int fdo, word; /* second pass flags; have word */ int doblank;/* field splitting of parameter/command subst */ - Expand x; /* expansion variables */ + Expand x = { + /* expansion variables */ + NULL, { NULL }, NULL, 0 + }; SubType st_head, *st; int newlines = 0; /* For trailing newlines in COMSUB */ int saw_eq, tilde_ok; @@ -265,7 +268,7 @@ expand(char *cp,/* input word */ { char *varname = ++sp; /* skip the { or x (}) */ int stype; - int slen; + int slen = 0; sp = strchr(sp, '\0') + 1; /* skip variable */ type = varsub(x, varname, sp, stype, slen);
Re: bug in COM-port subsystem
2011/3/11 Anton Maksimenkov anton...@gmail.com: If some process can catch COM port in a way that noone can use the port and noone can kill that process - it is wrong situation. I think this would be a little bit better: --- /usr/origsrc/sys/kern/tty.c Mon Oct 11 22:20:15 2010 +++ /usr/src/sys/kern/tty.c Fri Mar 11 22:57:48 2011 @@ -1188,7 +1188,8 @@ int ttywait(struct tty *tp) { - int error, s; + int error, s, tm; + struct proc *p = curproc; error = 0; s = spltty(); @@ -1200,8 +1201,15 @@ (ISSET(tp-t_state, TS_CARR_ON) || ISSET(tp-t_cflag, CLOCAL)) tp-t_oproc) { SET(tp-t_state, TS_ASLEEP); - error = ttysleep(tp, tp-t_outq, TTOPRI | PCATCH, ttyout, 0); + if (p-p_flag P_WEXIT) + tm = 100; + else + tm = 0; + error = ttysleep(tp, tp-t_outq, TTOPRI | PCATCH, ttyout, tm); if (error) + break; + /* If the process exiting we have to exit */ + if (p-p_flag P_WEXIT) break; } else break; -- antonvm
Re: thinkpad mute mic key
On Mon, Mar 14, 2011 at 05:52:41AM +, Jacob Meuser wrote: I like this *MUCH* better than the way acpithinkpad volume buttons currently work. these buttons should be affecting the mixer, if at all possible, instead of doing things behind the audio system's back, which causes confusion. FWIW, there's also a BIOS bug for some Thinkpad models concerning the handling of the regular 'mute' button: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/595896 So applying this to both mute buttons would also fix that.
[PATCH] Fix for kernel crash with udav(4) device
This device: udav0 at uhub5 port 2 ShanTou DM9601 rev 1.10/1.01 addr 2 udav0: address 00:60:6e:00:6e:20 amphy0 at udav0 phy 0: DM9601 10/100 PHY, rev. 0 causes a kernel crash with the following messages: memcpy() at memcpy+0x16 usb_transfer_complete() at usb_transfer_complete+0x256 uhci_softintr() at uchi_softintr+0x40 softintr_dispatch() at softintr_dispatch+0x5d end trace frame:0x0,count:-5 Using printf() with total_len shows that at certain times, it is 54768, where it should be less than the maximum frame size. Experimentally, the maximum value of total_len is 1514, but in if_udavreg.h, it is 1536. Index: src/sys/dev/usb/if_udav.c === RCS file: /cvs/src/sys/dev/usb/if_udav.c,v retrieving revision 1.51 diff -u -p -r1.51 if_udav.c --- src/sys/dev/usb/if_udav.c 25 Jan 2011 20:03:35 - 1.51 +++ src/sys/dev/usb/if_udav.c 14 Mar 2011 12:17:40 - @@ -1139,6 +1139,7 @@ udav_rxeof(usbd_xfer_handle xfer, usbd_p } if (total_len sizeof(struct ether_header) || + total_len UDAV_MAX_MTU || h-pktstat UDAV_RSR_ERR) { ifp-if_ierrors++; goto done;
Vreme je za prolećno čišćenje uz poklon
Zima je konaD no prošla... Vreme je za proleDno D išDenje! Neka vaš dom zablista uz najbolje Top Shop proizvode za D išDenje, a vi uEivajte u više slobodnog vremena! Kliknite ovde i odaberite najbolje za blistav dom. Završite kuDne poslove za kraDe vreme - neka drugi rade umesto vas! POKLON Color Catcher - papiriDi za spreD avanje bojenja veša uz svaki proizvod! Ponuda vaEi samo za internet i traje do 1.4.2011! Kliknite ovde i pogledajte sve proizvode za proleDno D išDenje: H2O X5 paroD istaD NOVI HIT! Vaša cena: 10.990 rsd Više b: Space Bag Cube Set + poklon! Space Bag Cube Vaša cena: 2.690 rsd Više b: Water Jet kompresor -50% + poklon! Water Jet kompresor Vaša cena: 1.290 rsd Više b: Ecogenie Ball + poklon! Ecogenie Ball Vaša cena: 5.490 rsd Više b: Space Bag Tote + poklon! Space Bag Tote Vaša cena: 4.990 rsd Više b: Spin Duster -15% + poklon! Spin Duster Vaša cena: 1.691,50 rsd Više b: ProleDno D išDenje DišDenje i spemanje moEe biti jednostavnije nego što mislite! Pogledajte 8 saveta za brEe spremanje: 1. DrEite sredstva za D išDenje na jednom mestu Ovako Dete lakše doDi do svega! 2. Pustite glasnu muziku Napravite listu pesama za spremanje - neka muzika bude energiD na i pozitivna. 3. PoD nite od prostorije koja vam je najdosadnija PoD nite od kutka koji najmanje volite, kada sa njim završite, sve ostalo De biti lakše... 4. Nemojte spremati radi spremanja Nemojte gubiti vreme na one stvari kojima D išDenje ne treba. 5. Distite usput Kada primetite da je nešto prljavo oD istite to odmah - tako Dete imati manje posla kasnije. 6. Od gore ka dole Uvek poD nite da D istite od gornjih površina ka dole. Ovako Dete izbeDi padanje prljavštine na D iste površine. 7. Suvo i mokro D išDenje PoD nite što više da D istite suvom krpom, izbeDi Dete fleke i ruEne tragove mokre krpe... 8. OdloEite sve za D išDenje Pobrinite se da sva 'oprema' za D išDenje bude uredno odloEena. Ovako je uvek sve spremno za sledeDi put! Mini pegla na paru + poklon! Mini Pegla na paru Vaša cena: 1.990 rsd Više b: Smart Pen - protiv ogrebotina + poklon! Smart Pen Vaša cena: 3.990 rsd Više b: Liquid Grout - za D išDenje fugni + poklon! Liquid Grout Vaša cena: 2.490 rsd Više b: POKLON uz svaki proizvod iz ove kategorije, samo na internetu do 1.4. poEurite! Ovu elektronsku poštu primate, ukoliko ste svojevoljno ostavili svoju e-mail adresu na nekom od sajtova Top Shop-a, uD estvovali u našoj poklon igri ili nagradnom kvizu ili se prijavili za e-D asopis Top Shop-a ili nekog od nasih brendova. Ponude date u ovom e-mailu vaEe iskljuD ivo za porudEbine upuDene putem Interneta ili broja telefona 021 489 26 60. Ukoliko ne Eelite više da primate naše elektronske poruke, za odjavljivanje sa naše e-mailing liste, kliknite ovde. Studio Moderna d.o.o., Bulevar vojvode Stepe 30, 21000 Novi Sad, Tel: 021 489 26 60, Fax: 021 489 29 08, E-mail: i...@news.top-shop.rs [IMAGE]If you would no longer like to receive our emails please unsubscribe by clicking here.
Re: fenv.h support for libm
On Sun, Mar 13, 2011 at 8:22 PM, Philip Guenther guent...@gmail.com wrote: Hmm, any test programs that are smaller and preferably not need X11? My little V100 takes forever with a build as is... I don't know of any at the moment. I'll try to look for something. You should be using __sparc64__ instead of __sparc__ and _NETBSD_SOURCE should be replaced with __BSD_VISIBLE. I'll second/confirm both of those. Note that it'll need to pull in sys/cdefs.h for the latter to work. It looks like they're relying on machine/fenv.h to pull in sys/cdefs.h. I can add an include in fenv.h too though. Other thoughts: The platform check in fenv.h should be moved inside the _FENV_H_ inclusion guard. Sure. Or maybe it can simply be removed: if the platform doesn't support it, then it won't have machine/fenv.h and the compilation will fail on the #include. I thought the not supported on this platform error's a bit more explanatory than failing to compile due to a missing include file. Saves some trouble of people asking why some fenv.h-using code doesn't compile on their ARM platform. Might want to wrap the function names in the declarations in fenv.h in parens, ala: int(feclearexcept)(int); so that possible future work to provide macros for those in machine/fenv.h don't have to go back and tweak them. Makes sense, but do we do this in other header files? I don't recall having seen this elsewhere. These headers violate POSIX namespace rules in various ways: - pulling in sys/stdint.h, machine/fpu.h, and i386/npx.h defines names that aren't permitted. (seems unnecessary too; just use unsigned short/int/long long instead of uint16_t/uint32_t/uint64_t) - the members of the fenv_t structures in the i386 and amd64 versions must have names in the implementation namespace, ala __control, __status, __x87, etc. I'll take a look at fixing this.
Re: fenv.h support for libm
On Tue, Mar 8, 2011 at 11:50 AM, Matthew Dempsky matt...@dempsky.org wrote: Currently, the diff only supports amd64, i386, and sparc64 (the only arches that NetBSD supports fenv.h on), I'd also appreciate help on adding support for the other platforms. Thanks!
Re: wprintf and friends
On Mon, Mar 14, 2011 at 12:29 AM, Amit Kulkarni amitk...@gmail.com wrote: I understand these need to be done right after lock. Might be you guys have better stuff planned than this stuff. Right after is a relative term. If adding wprintf goes smoothly, then there's plenty of time for wscanf. If adding wprintf does not go smoothly, adding wscanf at the same time will not make things smoother.
mfi(4): use 64-bit frames (unconditionally?)
the following diff make mfi(4) use 64-bit frames, and support 64-bit dma addresses. these changes are based on freebsd's mfi(4). however, freebsd only uses 64-bit frames 'if (sizeof(bus_addr_t)) == 8', whereas this patch uses 64-bit frames unconditionally, for both 32-bit and 64-bit platforms. I did it unconditionally, because it makes the code a bit simpler. according to my tests, this does have a slightly negative speed impact on i386. I've tested it with the following script. #!/bin/sh for i in 1 2 3 do cd /usr/obj sudo rm -rf * cd /usr/src time (make -j4 obj /dev/null 21 \ make -j4 includes /dev/null 21 \ make -j4 build /dev/null 21) done I ran this twice on each combination of i386/amd64, current code/with patch. these are the results (numbers after each run are the mean averages for that run): i386 32-bit mfi frames (current code) run 1 32m11.25s real33m48.65s user10m42.95s system 32m25.02s real33m51.56s user10m50.86s system 32m32.85s real33m51.49s user10m54.01s system 32m23.04s 33m50.57s 10m49.27s run 2 32m32.08s real33m51.22s user10m49.67s system 32m26.76s real33m47.27s user10m52.08s system 32m34.42s real33m46.22s user10m51.88s system 32m31.09s 33m48.24s 10m51.21s 64-bit mfi frames (with patch) run 1 32m39.15s real33m38.95s user10m59.97s system 32m24.67s real33m36.85s user11m6.44s system 32m25.48s real33m35.04s user11m3.67s system 32m29.76s 33m36.95s 11m3.20s run 2 32m25.55s real33m39.58s user11m6.11s system 33m04.37s real33m34.70s user11m9.84s system 32m33.54s real33m41.38s user11m7.65s system 32m41.15s 33m38.55s 11m7.87s amd64 32-bit mfi frames (current code) run 1 17m43.44s real17m49.14s user 8m19.46s system 17m51.65s real17m49.07s user 8m29.63s system 17m50.89s real17m49.28s user 8m28.45s system 17m48.66s 17m49.16s 8m25.85s run 2 17m49.82s real17m47.05s user 8m32.91s system 17m49.68s real17m51.12s user 8m27.38s system 17m51.37s real17m47.93s user 8m33.09s system 17m50.29s 17m48.70s 8m31.13s 64-bit mfi frames (with patch) run 1 17m44.04s real17m51.22s user 8m21.02s system 17m51.86s real17m51.00s user 8m28.67s system 17m51.87s real17m50.50s user 8m30.44s system 17m49.26s 17m51.04s 8m26.71s run 2 17m54.74s real17m54.06s user 8m29.78s system 17m53.51s real17m49.95s user 8m33.98s system 17m50.85s real17m49.76s user 8m32.85s system 17m53.03s 17m51.26s 8m32.20s so, the question is, is the impact on i386 enough to warrant using 32-bit frames on 32-bit platforms? if so, should this be decided at runtime or compile time? any other thoughts? -- jake...@sdf.lonestar.org SDF Public Access UNIX System - http://sdf.lonestar.org Index: mfi.c === RCS file: /cvs/src/sys/dev/ic/mfi.c,v retrieving revision 1.114 diff -u -p mfi.c --- mfi.c 30 Dec 2010 08:53:50 - 1.114 +++ mfi.c 14 Mar 2011 20:05:59 - @@ -618,7 +618,7 @@ int mfi_attach(struct mfi_softc *sc, enum mfi_iop iop) { struct scsibus_attach_args saa; - uint32_tstatus, frames; + uint32_tstatus, frames, max_sgl; int i; switch (iop) { @@ -648,7 +648,8 @@ mfi_attach(struct mfi_softc *sc, enum mfi_iop iop) status = mfi_fw_state(sc); sc-sc_max_cmds = status MFI_STATE_MAXCMD_MASK; - sc-sc_max_sgl = (status MFI_STATE_MAXSGL_MASK) 16; + max_sgl = (status MFI_STATE_MAXSGL_MASK) 16; + sc-sc_max_sgl = min(max_sgl, (128 * 1024) / PAGE_SIZE + 1); DNPRINTF(MFI_D_MISC, %s: max commands: %u, max sgl: %u\n, DEVNAME(sc), sc-sc_max_cmds, sc-sc_max_sgl); @@ -662,8 +663,7 @@ mfi_attach(struct mfi_softc *sc, enum mfi_iop iop) } /* frame memory */ - /* we are not doing 64 bit IO so only calculate # of 32 bit frames */ - frames = (sizeof(struct mfi_sg32) * sc-sc_max_sgl + + frames = (sizeof(struct mfi_sgl) * sc-sc_max_sgl + MFI_FRAME_SIZE - 1) / MFI_FRAME_SIZE + 1; sc-sc_frames_size = frames * MFI_FRAME_SIZE; sc-sc_frames = mfi_allocmem(sc, sc-sc_frames_size * sc-sc_max_cmds); @@ -1105,7 +1105,7 @@ mfi_create_sgl(struct mfi_ccb *ccb, int flags) struct mfi_softc*sc = ccb-ccb_sc; struct mfi_frame_header *hdr; bus_dma_segment_t *sgd; - union mfi_sgl *sgl; + struct mfi_sgl *sgl; int error, i; DNPRINTF(MFI_D_DMA, %s: mfi_create_sgl
remove SILLY
remove unused SILLY game of life. no binary change. ok? Index: config.h === RCS file: /home/okan/hack/open/cvs/src/bin/ksh/config.h,v retrieving revision 1.13 diff -u -p -r1.13 config.h --- config.h18 Dec 2004 22:42:26 - 1.13 +++ config.h14 Mar 2011 14:06:04 - @@ -32,9 +32,6 @@ /* Specify default $ENV? */ /* #undef DEFAULT_ENV */ -/* Include game-of-life? */ -/* #undef SILLY */ - /* The number of bytes in a int. */ #define SIZEOF_INT 4 Index: emacs.c === RCS file: /home/okan/hack/open/cvs/src/bin/ksh/emacs.c,v retrieving revision 1.42 diff -u -p -r1.42 emacs.c --- emacs.c 2 Jun 2009 06:47:47 - 1.42 +++ emacs.c 14 Mar 2011 14:08:42 - @@ -205,11 +205,7 @@ static const struct x_ftab x_ftab[] = { { x_fold_upper, upcase-word, XF_ARG }, { x_set_arg,set-arg, XF_NOBIND }, { x_comment,comment, 0 }, -#ifdef SILLY - { x_game_of_life, play-game-of-life,0 }, -#else { 0, 0, 0 }, -#endif #ifdef DEBUG { x_debug_info, debug-info, 0 }, #else @@ -1534,62 +1530,9 @@ x_noop(int c) return KSTD; } -#ifdef SILLY -static int -x_game_of_life(int c) -{ - charnewbuf [256+1]; - char*ip, *op; - int i, len; - - i = xep - xbuf; - *xep = 0; - len = x_size_str(xbuf); - xcp = xbp = xbuf; - memmove(newbuf+1, xbuf, i); - newbuf[0] = 'A'; - newbuf[i] = 'A'; - for (ip = newbuf+1, op = xbuf; --i = 0; ip++, op++) { - /* Empty space */ - if (*ip '@' || *ip == '_' || *ip == 0x7F) { - /* Two adults, make whoopee */ - if (ip[-1] '_' ip[1] '_') { - /* Make kid look like parents. */ - *op = '`' + ((ip[-1] + ip[1])/2)%32; - if (*op == 0x7F) /* Birth defect */ - *op = '`'; - } - else - *op = ' '; /* nothing happens */ - continue; - } - /* Child */ - if (*ip '`') { - /* All alone, dies */ - if (ip[-1] == ' ' ip[1] == ' ') - *op = ' '; - else/* Gets older */ - *op = *ip-'`'+'@'; - continue; - } - /* Adult */ - /* Overcrowded, dies */ - if (ip[-1] = '@' ip[1] = '@') { - *op = ' '; - continue; - } - *op = *ip; - } - *op = 0; - x_redraw(len); - return KSTD; -} -#endif - /* * File/command name completion routines */ - static int x_comp_comm(int c)
remove disabled FP support
pull out the never enabled fp support. no binary change. ok? Index: ksh_limval.h === RCS file: /home/okan/hack/open/cvs/src/bin/ksh/ksh_limval.h,v retrieving revision 1.2 diff -u -p -r1.2 ksh_limval.h --- ksh_limval.h18 Dec 2004 20:55:52 - 1.2 +++ ksh_limval.h14 Mar 2011 10:03:41 - @@ -4,10 +4,6 @@ /* limits.h is included in sh.h */ -#ifndef DMAXEXP -# define DMAXEXP 128 /* should be big enough */ -#endif - #ifndef BITS # define BITS(t) (CHAR_BIT * sizeof(t)) #endif Index: shf.c === RCS file: /home/okan/hack/open/cvs/src/bin/ksh/shf.c,v retrieving revision 1.15 diff -u -p -r1.15 shf.c --- shf.c 2 Apr 2006 00:48:33 - 1.15 +++ shf.c 14 Mar 2011 10:03:19 - @@ -705,15 +705,7 @@ shf_smprintf(const char *fmt, ...) return shf_sclose(shf); /* null terminates */ } -#undef FP /* if you want floating point stuff */ - #define BUF_SIZE 128 -#define FPBUF_SIZE (DMAXEXP+16)/* this must be -* MAX(DMAXEXP, log10(pow(2, DSIGNIF))) -*+ ceil(log10(DMAXEXP)) + 8 (I think). -* Since this is hard to express as a -* constant, just use a large buffer. -*/ /* * What kinda of machine we on? Hopefully the C compiler will optimize @@ -744,18 +736,6 @@ shf_smprintf(const char *fmt, ...) #define FL_NUMBER 0x200 /* a number was formated %[douxefg] */ -#ifdef FP -#include math.h - -static double -my_ceil(double d) -{ - double i; - - return d - modf(d, i) + (d 0 ? -1 : 1); -} -#endif /* FP */ - int shf_vfprintf(struct shf *shf, const char *fmt, va_list args) { @@ -769,17 +749,6 @@ shf_vfprintf(struct shf *shf, const char charnumbuf[(BITS(long) + 2) / 3 + 1]; /* this stuff for dealing with the buffer */ int nwritten = 0; -#ifdef FP - /* should be in math.h -* extern double frexp(); -*/ - extern char *ecvt(); - - double fpnum; - int expo, decpt; - charstyle; - charfpbuf[FPBUF_SIZE]; -#endif /* FP */ if (!fmt) return 0; @@ -946,134 +915,6 @@ shf_vfprintf(struct shf *shf, const char precision = len; /* no loss */ } break; - -#ifdef FP - case 'e': - case 'g': - case 'f': - { - char *p; - - /* -* This could probably be done better, -* but it seems to work. Note that gcvt() -* is not used, as you cannot tell it to -* not strip the zeros. -*/ - flags |= FL_NUMBER; - if (!(flags FL_DOT)) - precision = 6; /* default */ - /* -* Assumes doubles are pushed on -* the stack. If this is not so, then -* FL_LONG/FL_SHORT should be checked. -*/ - fpnum = va_arg(args, double); - s = fpbuf; - style = c; - /* -* This is the same as -* expo = ceil(log10(fpnum)) -* but doesn't need -lm. This is an -* approximation as expo is rounded up. -*/ - (void) frexp(fpnum, expo); - expo = my_ceil(expo / LOG2_10); - - if (expo 0) - expo = 0; - - p = ecvt(fpnum, precision + 1 + expo, -decpt, tmp); - if (c == 'g') { - if (decpt -4 || decpt precision) - style = 'e'; - else - style = 'f'; - if (decpt 0 (precision -= decpt) 0) - precision = 0; - } - if (tmp) - *s++ = '-'; - else if (flags FL_PLUS) - *s++ = '+'; - else if (flags FL_BLANK) - *s++ = ' '; - - if (style == 'e') - *s++ = *p++; - else { -
Re: mfi(4): use 64-bit frames (unconditionally?)
On Mon, Mar 14, 2011 at 4:29 PM, Jacob Meuser jake...@sdf.lonestar.org wrote: i386 32-bit mfi frames (current code) 32m23.04s 33m50.57s 10m49.27s 32m31.09s 33m48.24s 10m51.21s 64-bit mfi frames (with patch) 32m29.76s 33m36.95s 11m3.20s 32m41.15s 33m38.55s 11m7.87s so, the question is, is the impact on i386 enough to warrant using 32-bit frames on 32-bit platforms? if so, should this be decided at runtime or compile time? I don't think so. It's under 1% in the worst case. That's a very small difference, and the fact that user time got *better* when it should have remained the same makes me think the difference is within the noise.
Add MDNS lookup for libc.
Hi, The following adds legacy MDNS lookups to libc. It adds the keyword 'mdns' to 'lookup' in /etc/resolv.conf, only names in the .local (MDNS domain) are looked up. A legacy lookup is how MDNS calls a simple unicast lookup sent to the mcast addr 224.0.0.251, the MDNS responder is responsible for identifying the legacy query and answering it via unicast, like a normal unicast domain server would do. In order to *answer* the queries you need a proper MDNS daemon running, OpenMDNS is now in ports and works fine. You could also run avahi or bonjour, but please try OpenMDNS instead :-). http://www.haesbaert.org/openmdns This approach is different from linux+avahi and netbsd+bonjour, in which they route the queries to the daemon in order to use standard MDNS queries. I've been using this in i386 and sparc64 for about a week, support for both getaddrinfo(3) and gethostbyname(3), AF_INET and AF_INET6, no support for reverse lookups yet. I'm still unfamiliar with the libc resolv code, so if I'm doing something wrong please correct me, I've tried to keep the code apart from the rest of the resolver. Index: net/getaddrinfo.c === RCS file: /cvs/src/lib/libc/net/getaddrinfo.c,v retrieving revision 1.71 diff -d -u -p -w -r1.71 getaddrinfo.c --- net/getaddrinfo.c 18 Nov 2009 07:43:22 - 1.71 +++ net/getaddrinfo.c 15 Mar 2011 00:56:20 - @@ -235,6 +235,8 @@ static int res_searchN(const char *, str static int res_querydomainN(const char *, const char *, struct res_target *); static struct addrinfo *_dns_getaddrinfo(const char *, const struct addrinfo *, const struct __res_state *); +static struct addrinfo *_mcast_getaddrinfo(const char *, +const struct addrinfo *, const struct __res_state *); /* XXX macros that make external reference is BAD. */ @@ -523,6 +525,9 @@ explore_fqdn(const struct addrinfo *pai, case 'f': result = _files_getaddrinfo(hostname, pai); break; + case 'm': + result = _mcast_getaddrinfo(hostname, pai, _resp); + break; } } _THREAD_PRIVATE_MUTEX_UNLOCK(_explore_mutex); @@ -1209,6 +1214,99 @@ _dns_getaddrinfo(const char *name, const free(buf); free(buf2); return NULL; + } + ai = getanswer(buf, q.n, q.name, q.qtype, pai); + if (ai) { + cur-ai_next = ai; + while (cur cur-ai_next) + cur = cur-ai_next; + } + if (q.next) { + ai = getanswer(buf2, q2.n, q2.name, q2.qtype, pai); + if (ai) + cur-ai_next = ai; + } + free(buf); + free(buf2); + return sentinel.ai_next; +} + +static struct addrinfo * +_mcast_getaddrinfo(const char *name, const struct addrinfo *pai, +const struct __res_state *_resp) +{ + struct addrinfo *ai; + querybuf *buf, *buf2; + struct addrinfo sentinel, *cur; + struct res_target q, q2; + + memset(q, 0, sizeof(q)); + memset(q2, 0, sizeof(q2)); + memset(sentinel, 0, sizeof(sentinel)); + cur = sentinel; + + buf = malloc(sizeof(*buf)); + if (buf == NULL) { + h_errno = NETDB_INTERNAL; + return NULL; + } + buf2 = malloc(sizeof(*buf2)); + if (buf2 == NULL) { + free(buf); + h_errno = NETDB_INTERNAL; + return NULL; + } + + switch (pai-ai_family) { + case AF_UNSPEC: + /* respect user supplied order */ + q.qclass = C_IN; + q.qtype = (_resp-family[0] == AF_INET6) ? T_ : T_A; + q.answer = buf-buf; + q.anslen = sizeof(buf-buf); + q.next = q2; + + if (_resp-family[1] == -1) { + /* stop here if only one family was given */ + q.next = NULL; + break; + } + + q2.qclass = C_IN; + q2.qtype = (_resp-family[1] == AF_INET6) ? T_ : T_A; + q2.answer = buf2-buf; + q2.anslen = sizeof(buf2-buf); + break; + case AF_INET: + q.qclass = C_IN; + q.qtype = T_A; + q.answer = buf-buf; + q.anslen = sizeof(buf-buf); + break; + case AF_INET6: + q.qclass = C_IN; + q.qtype = T_; + q.answer = buf-buf; + q.anslen = sizeof(buf-buf); + break; + default: + free(buf); + free(buf2); + return NULL; + } + if ((q.n = res_search_mcast(name, + q.qclass, q.qtype, q.answer, q.anslen)) 0) { + free(buf); + free(buf2); +