Re: Synaptics touchpad
Thanks to both of you, it works fairly well on my Acer Aspire 5551 laptop with Synaptics 7.2 firmware. What's the prefered method of configuration? xorg.conf/synclient or xinput? I use the following from .xintrc/.xsession: synclient TapButton1=1 synclient TapButton2=2 synclient TapButton3=3 synclient VertEdgeScroll=1 synclient VertTwoFingerScroll=0 syndaemon -d -t -K The sensitivity is a bit high for tap-to-click though, especially for buttons 2 and 3.. for bringing up cwm menu's, etc. It's still something that has been missing for a long time, the physical buttons are annoying to use on my laptop.. fortunately button 1 was implemented in the firmware (..and hence worked with xf86-input-mouse). -Bryan.
Davetiyeniz var
Merhaba, Davetiyeniz var Bu email gvremiyorsan}z L|tfen T}klay}n}z. http://kenttefirsat.rvs0.com/trc/sv/LT?T=4bdhg&R=11179689 E-posta almak istemiyorsan}z |yelikten g}kmak igin l|tfen t}klay}n http://kenttefirsat.rvs0.net.frm/sv/sb?fid=004&rr=11179689&rk=77xE&c=7249 032
Re: mixerctl(1) diff: sort output
On Mon, May 09, 2011 at 01:32:49AM +0300, Sviatoslav Chagaev wrote: > * sorted output looks cleaner, prettier; > * it's easier to find the variable you're looking for in a sorted > output; > * hierarchical variable names yet unordered? doesn't make sense; > * this way mixerctl's behaviour will be closer to other *ctl programs > which output variables in an ordered fashion (audioctl, sysctl, > wsconsctl). these are all matters of opinion, except for "hierarchical variable names" which is not technically the case here. > Before: note how the controls are grouped (mostly) by "widget". please read azalia(4). > s@d630:0:/usr/src/usr.bin/mixerctl$ mixerctl > outputs.hp_source=dac-0:1 > outputs.hp_dir=output > outputs.hp_boost=off > outputs.line-in_source=dac-2:3 > outputs.line-in_dir=input > outputs.mic_dir=input-vr80 > outputs.spkr_source=dac-2:3 > outputs.spkr_dir=none > outputs.spkr_boost=off > inputs.dac-2:3_mute=off > inputs.dac-2:3=152,152 > inputs.dac-0:1_mute=off > inputs.dac-0:1=152,152 > inputs.sel_source=mic > outputs.sel=126,126 > inputs.sel2_source=line-in > outputs.sel2=126,126 > inputs.sel3_source=sel > inputs.sel3_sel=119,119 > inputs.sel4_source=sel2 > inputs.sel4_sel2=119,119 > record.adc-0:1_source=sel3 > record.adc-0:1_mute=off > record.adc-2:3_source=sel4 > record.adc-2:3_mute=off > inputs.beep=85 and at the end are the "pseudo" controls. the ones most people are most interested in. so even if the rest of the controls scroll by when you do a simple "mixerctl", you see these controls. > outputs.hp_sense=plugged > outputs.line-in_sense=unplugged > outputs.spkr_muters=hp,line-in > outputs.master=153,153 > outputs.master.mute=off > outputs.master.slaves=dac-2:3,dac-0:1 > record.volume=0,0 > record.volume.mute=off > record.volume.slaves=adc-0:1,adc-2:3 > > After: > s@d630:0:/usr/src/usr.bin/mixerctl$ ./mixerctl > inputs.beep=85 > inputs.dac-0:1=152,152 > inputs.dac-0:1_mute=off > inputs.dac-2:3=152,152 > inputs.dac-2:3_mute=off > inputs.sel2_source=line-in > inputs.sel3_sel=119,119 > inputs.sel3_source=sel > inputs.sel4_sel2=119,119 > inputs.sel4_source=sel2 > inputs.sel_source=mic > outputs.hp_boost=off > outputs.hp_dir=output > outputs.hp_sense=plugged > outputs.hp_source=dac-0:1 > outputs.line-in_dir=input > outputs.line-in_sense=unplugged > outputs.line-in_source=dac-2:3 > outputs.master=153,153 > outputs.master.mute=off > outputs.master.slaves=dac-2:3,dac-0:1 > outputs.mic_dir=input-vr80 > outputs.sel=126,126 > outputs.sel2=126,126 > outputs.spkr_boost=off > outputs.spkr_dir=none > outputs.spkr_muters=hp,line-in > outputs.spkr_source=dac-2:3 > record.adc-0:1_mute=off > record.adc-0:1_source=sel3 > record.adc-2:3_mute=off > record.adc-2:3_source=sel4 > record.volume=0,0 > record.volume.mute=off > record.volume.slaves=adc-0:1,adc-2:3 I do not find this more useful. prettier, perhaps, but not more useful. in particular, this (further) breaks the widget-wise grouping on some devices. please read azalia(4), "inputs" and "outputs" is really just a hint, and making it more precise is much more difficult than adding sorting to mixerctl ... > > > Index: mixerctl.c > === > RCS file: /OpenBSD/src/usr.bin/mixerctl/mixerctl.c,v > retrieving revision 1.29 > diff -u -r1.29 mixerctl.c > --- mixerctl.c12 Nov 2009 07:27:31 - 1.29 > +++ mixerctl.c8 May 2011 22:25:03 - > @@ -46,23 +46,21 @@ > #include > #include > > -struct field *findfield(char *); > -void adjlevel(char **, u_char *, int); > -void catstr(char *, char *, char *); > -void prfield(struct field *, char *, int, mixer_ctrl_t *); > -void rdfield(int, struct field *, char *, int, char *); > -__dead void usage(void); > - > #define FIELD_NAME_MAX 64 > > struct field { > char name[FIELD_NAME_MAX]; > mixer_ctrl_t *valp; > mixer_devinfo_t *infp; > -} *fields, *rfields; > +}; > > -mixer_ctrl_t *values; > -mixer_devinfo_t *infos; > +int fieldcmp(const void *, const void *); > +int fieldnamecmp(const void *, const void *); > +void adjlevel(char **, u_char *, int); > +void catstr(char *, char *, char *); > +void prfield(struct field *, char *, int, mixer_ctrl_t *); > +void rdfield(int, struct field *, char *, int, char *); > +__dead void usage(void); > > void > catstr(char *p, char *q, char *out) > @@ -73,14 +71,19 @@ > strlcpy(out, tmp, FIELD_NAME_MAX); > } > > -struct field * > -findfield(char *name) > +int > +fieldcmp(const void *pa, const void *pb) > { > - int i; > - for (i = 0; fields[i].name[0] != '\0'; i++) > - if (strcmp(fields[i].name, name) == 0) > - return &fields[i]; > - return (0); > + const struct field *a = pa, *b = pb; > + return strcmp(a->name, b->name); > +} > + > +int > +fieldnamecmp(const void *pa, const void *pb) > +{ > + const char *name = pa; > + const struct field
Re: mixerctl(1) diff: sort output
On Sun, May 8, 2011 at 5:32 PM, Sviatoslav Chagaev wrote: > * sorted output looks cleaner, prettier; > * it's easier to find the variable you're looking for in a sorted > output; > * hierarchical variable names yet unordered? doesn't make sense; > * this way mixerctl's behaviour will be closer to other *ctl programs > which output variables in an ordered fashion (audioctl, sysctl, > wsconsctl). > > Before: > s@d630:0:/usr/src/usr.bin/mixerctl$ mixerctl > outputs.hp_source=dac-0:1 > outputs.hp_dir=output > outputs.hp_boost=off > outputs.line-in_source=dac-2:3 > outputs.line-in_dir=input > outputs.mic_dir=input-vr80 > outputs.spkr_source=dac-2:3 > outputs.spkr_dir=none > outputs.spkr_boost=off > inputs.dac-2:3_mute=off > inputs.dac-2:3=152,152 > inputs.dac-0:1_mute=off > inputs.dac-0:1=152,152 > inputs.sel_source=mic > outputs.sel=126,126 > inputs.sel2_source=line-in > outputs.sel2=126,126 > inputs.sel3_source=sel > inputs.sel3_sel=119,119 > inputs.sel4_source=sel2 > inputs.sel4_sel2=119,119 > record.adc-0:1_source=sel3 > record.adc-0:1_mute=off > record.adc-2:3_source=sel4 > record.adc-2:3_mute=off > inputs.beep=85 > outputs.hp_sense=plugged > outputs.line-in_sense=unplugged > outputs.spkr_muters=hp,line-in > outputs.master=153,153 > outputs.master.mute=off > outputs.master.slaves=dac-2:3,dac-0:1 > record.volume=0,0 > record.volume.mute=off > record.volume.slaves=adc-0:1,adc-2:3 > > After: > s@d630:0:/usr/src/usr.bin/mixerctl$ ./mixerctl > inputs.beep=85 > inputs.dac-0:1=152,152 > inputs.dac-0:1_mute=off > inputs.dac-2:3=152,152 > inputs.dac-2:3_mute=off > inputs.sel2_source=line-in > inputs.sel3_sel=119,119 > inputs.sel3_source=sel > inputs.sel4_sel2=119,119 > inputs.sel4_source=sel2 > inputs.sel_source=mic > outputs.hp_boost=off > outputs.hp_dir=output > outputs.hp_sense=plugged > outputs.hp_source=dac-0:1 > outputs.line-in_dir=input > outputs.line-in_sense=unplugged > outputs.line-in_source=dac-2:3 > outputs.master=153,153 > outputs.master.mute=off > outputs.master.slaves=dac-2:3,dac-0:1 > outputs.mic_dir=input-vr80 > outputs.sel=126,126 > outputs.sel2=126,126 > outputs.spkr_boost=off > outputs.spkr_dir=none > outputs.spkr_muters=hp,line-in > outputs.spkr_source=dac-2:3 > record.adc-0:1_mute=off > record.adc-0:1_source=sel3 > record.adc-2:3_mute=off > record.adc-2:3_source=sel4 > record.volume=0,0 > record.volume.mute=off > record.volume.slaves=adc-0:1,adc-2:3 > > > > Index: mixerctl.c > === > RCS file: /OpenBSD/src/usr.bin/mixerctl/mixerctl.c,v > retrieving revision 1.29 > diff -u -r1.29 mixerctl.c > --- mixerctl.c B 12 Nov 2009 07:27:31 - B B B 1.29 > +++ mixerctl.c B 8 May 2011 22:25:03 - > @@ -46,23 +46,21 @@ > B #include > B #include > > -struct field *findfield(char *); > -void adjlevel(char **, u_char *, int); > -void catstr(char *, char *, char *); > -void prfield(struct field *, char *, int, mixer_ctrl_t *); > -void rdfield(int, struct field *, char *, int, char *); > -__dead void usage(void); > - > B #define FIELD_NAME_MAX 64 > > B struct field { > B B B B char name[FIELD_NAME_MAX]; > B B B B mixer_ctrl_t *valp; > B B B B mixer_devinfo_t *infp; > -} *fields, *rfields; > +}; > > -mixer_ctrl_t *values; > -mixer_devinfo_t *infos; > +int B B B B B B fieldcmp(const void *, const void *); > +int B B B B B B fieldnamecmp(const void *, const void *); > +void B B B B B B adjlevel(char **, u_char *, int); > +void B B B B B B catstr(char *, char *, char *); > +void B B B B B B prfield(struct field *, char *, int, mixer_ctrl_t *); > +void B B B B B B rdfield(int, struct field *, char *, int, char *); > +__dead void B B usage(void); > > B void > B catstr(char *p, char *q, char *out) > @@ -73,14 +71,19 @@ > B B B B strlcpy(out, tmp, FIELD_NAME_MAX); > B } > > -struct field * > -findfield(char *name) > +int > +fieldcmp(const void *pa, const void *pb) > B { > - B B B int i; > - B B B for (i = 0; fields[i].name[0] != '\0'; i++) > - B B B B B B B if (strcmp(fields[i].name, name) == 0) > - B B B B B B B B B B B return &fields[i]; > - B B B return (0); > + B B B const struct field *a = pa, *b = pb; > + B B B return strcmp(a->name, b->name); > +} > + > +int > +fieldnamecmp(const void *pa, const void *pb) > +{ > + B B B const char *name = pa; > + B B B const struct field *f = pb; > + B B B return strcmp(name, f->name); > B } > > B #define e_member_name B un.e.member[i].label.name > @@ -241,12 +244,15 @@ > B int > B main(int argc, char **argv) > B { > - B B B int fd, i, j, ch, pos; > + B B B int fd, i, ch, pos; > B B B B int aflag = 0, qflag = 0, vflag = 0, tflag = 0; > B B B B char *file; > B B B B char *sep = "="; > - B B B mixer_devinfo_t dinfo; > + B B B mixer_devinfo_t dinfo, *infos; > + B B B mixer_ctrl_t *values; > B B B B int ndev; > + B B B struct field *fields, *rfields; > + B B B int nfields; > > B B B B if (
pciide/wdc ata_drive_datas init refactoring; testers wanted!
wdcattach() currently doesn't initialize its ata_drive_datas fields until late in the function, so a few pciide drv_probe routines need to initialize it themselves. Simply moving the initialization before calling drv_probe() lets us get rid of this extra code. Test reports from any machine with pciide(4)/wdc(4) is appreciated, but especially if you have one of the following pciide chipsets (i.e., chipsets with affected drv_probe() code): ATI SB300 SATA (0x1002:0x436e) ATI SB400 SATA (0x1002:0x4379) ATI SB400 SATA (0x1002:0x437a) CMD Technology SiI3112 SATA (0x1095:0x3112) CMD Technology SiI3114 SATA (0x1095:0x3114) CMD Technology SiI3512 SATA (0x1095:0x3512) CMD Technology AAR-1210SA (0x1095:0x0240) Promise PDC20571 (0x105a:0x3571) Promise PDC20575 (0x105a:0x3d75) Promise PDC20579 (0x105a:0x3574) Promise PDC20771 (0x105a:0x3570) Promise PDC20775 (0x105a:0x3d73) Promise PDC40518 (0x105a:0x3d18) Promise PDC40519 (0x105a:0x3519) Promise PDC40718 (0x105a:0x3d17) Promise PDC40719 (0x105a:0x3515) Promise PDC40779 (0x105a:0x3577) ServerWorks Frodo4 SATA (0x1166:0x0241) ServerWorks Frodo8 SATA (0x1166:0x0242) ServerWorks HT-1000 SATA (0x1166:0x024a) ServerWorks HT-1000 SATA (0x1166:0x024b) ServerWorks K2 SATA (0x1166:0x0240) Index: ic/wdc.c === RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/ic/wdc.c,v retrieving revision 1.114 diff -u -p -r1.114 wdc.c --- ic/wdc.c8 May 2011 17:33:56 - 1.114 +++ ic/wdc.c8 May 2011 22:44:53 - @@ -718,6 +718,11 @@ wdcattach(struct channel_softc *chp) if (!chp->_vtbl) chp->_vtbl = &wdc_default_vtbl; + for (i = 0; i < 2; i++) { + chp->ch_drive[i].chnl_softc = chp; + chp->ch_drive[i].drive = i; + } + if (chp->wdc->drv_probe != NULL) { chp->wdc->drv_probe(chp); } else { @@ -756,8 +761,6 @@ wdcattach(struct channel_softc *chp) for (i = 0; i < 2; i++) { struct ata_drive_datas *drvp = &chp->ch_drive[i]; - drvp->chnl_softc = chp; - drvp->drive = i; /* If controller can't do 16bit flag the drives as 32bit */ if ((chp->wdc->cap & (WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32)) == Index: pci/pciide.c === RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/pci/pciide.c,v retrieving revision 1.328 diff -u -p -r1.328 pciide.c --- pci/pciide.c27 Apr 2011 07:55:05 - 1.328 +++ pci/pciide.c8 May 2011 22:46:35 - @@ -4301,13 +4301,7 @@ sii3112_drv_probe(struct channel_softc * struct pciide_softc *sc = (struct pciide_softc *)cp->wdc_channel.wdc; uint32_t scontrol, sstatus; uint8_t scnt, sn, cl, ch; - int i, s; - - /* XXX This should be done by other code. */ - for (i = 0; i < 2; i++) { - chp->ch_drive[i].chnl_softc = chp; - chp->ch_drive[i].drive = i; - } + int s; /* * The 3112 is a 2-port part, and only has one drive per channel @@ -7103,13 +7097,7 @@ pdc205xx_drv_probe(struct channel_softc bus_space_handle_t *iohs; u_int32_t scontrol, sstatus; u_int16_t scnt, sn, cl, ch; - int i, s; - - /* XXX This should be done by other code. */ - for (i = 0; i < 2; i++) { - chp->ch_drive[i].chnl_softc = chp; - chp->ch_drive[i].drive = i; - } + int s; SCONTROL_WRITE(ps, chp->channel, 0); delay(50*1000); @@ -7763,13 +7751,7 @@ svwsata_drv_probe(struct channel_softc * int channel = chp->channel; uint32_t scontrol, sstatus; uint8_t scnt, sn, cl, ch; - int i, s; - - /* XXX This should be done by other code. */ - for (i = 0; i < 2; i++) { - chp->ch_drive[i].chnl_softc = chp; - chp->ch_drive[i].drive = i; - } + int s; /* * Request communication initialization sequence, any speed.
mixerctl(1) diff: sort output
* sorted output looks cleaner, prettier; * it's easier to find the variable you're looking for in a sorted output; * hierarchical variable names yet unordered? doesn't make sense; * this way mixerctl's behaviour will be closer to other *ctl programs which output variables in an ordered fashion (audioctl, sysctl, wsconsctl). Before: s@d630:0:/usr/src/usr.bin/mixerctl$ mixerctl outputs.hp_source=dac-0:1 outputs.hp_dir=output outputs.hp_boost=off outputs.line-in_source=dac-2:3 outputs.line-in_dir=input outputs.mic_dir=input-vr80 outputs.spkr_source=dac-2:3 outputs.spkr_dir=none outputs.spkr_boost=off inputs.dac-2:3_mute=off inputs.dac-2:3=152,152 inputs.dac-0:1_mute=off inputs.dac-0:1=152,152 inputs.sel_source=mic outputs.sel=126,126 inputs.sel2_source=line-in outputs.sel2=126,126 inputs.sel3_source=sel inputs.sel3_sel=119,119 inputs.sel4_source=sel2 inputs.sel4_sel2=119,119 record.adc-0:1_source=sel3 record.adc-0:1_mute=off record.adc-2:3_source=sel4 record.adc-2:3_mute=off inputs.beep=85 outputs.hp_sense=plugged outputs.line-in_sense=unplugged outputs.spkr_muters=hp,line-in outputs.master=153,153 outputs.master.mute=off outputs.master.slaves=dac-2:3,dac-0:1 record.volume=0,0 record.volume.mute=off record.volume.slaves=adc-0:1,adc-2:3 After: s@d630:0:/usr/src/usr.bin/mixerctl$ ./mixerctl inputs.beep=85 inputs.dac-0:1=152,152 inputs.dac-0:1_mute=off inputs.dac-2:3=152,152 inputs.dac-2:3_mute=off inputs.sel2_source=line-in inputs.sel3_sel=119,119 inputs.sel3_source=sel inputs.sel4_sel2=119,119 inputs.sel4_source=sel2 inputs.sel_source=mic outputs.hp_boost=off outputs.hp_dir=output outputs.hp_sense=plugged outputs.hp_source=dac-0:1 outputs.line-in_dir=input outputs.line-in_sense=unplugged outputs.line-in_source=dac-2:3 outputs.master=153,153 outputs.master.mute=off outputs.master.slaves=dac-2:3,dac-0:1 outputs.mic_dir=input-vr80 outputs.sel=126,126 outputs.sel2=126,126 outputs.spkr_boost=off outputs.spkr_dir=none outputs.spkr_muters=hp,line-in outputs.spkr_source=dac-2:3 record.adc-0:1_mute=off record.adc-0:1_source=sel3 record.adc-2:3_mute=off record.adc-2:3_source=sel4 record.volume=0,0 record.volume.mute=off record.volume.slaves=adc-0:1,adc-2:3 Index: mixerctl.c === RCS file: /OpenBSD/src/usr.bin/mixerctl/mixerctl.c,v retrieving revision 1.29 diff -u -r1.29 mixerctl.c --- mixerctl.c 12 Nov 2009 07:27:31 - 1.29 +++ mixerctl.c 8 May 2011 22:25:03 - @@ -46,23 +46,21 @@ #include #include -struct field *findfield(char *); -void adjlevel(char **, u_char *, int); -void catstr(char *, char *, char *); -void prfield(struct field *, char *, int, mixer_ctrl_t *); -void rdfield(int, struct field *, char *, int, char *); -__dead void usage(void); - #define FIELD_NAME_MAX 64 struct field { char name[FIELD_NAME_MAX]; mixer_ctrl_t *valp; mixer_devinfo_t *infp; -} *fields, *rfields; +}; -mixer_ctrl_t *values; -mixer_devinfo_t *infos; +int fieldcmp(const void *, const void *); +int fieldnamecmp(const void *, const void *); +voidadjlevel(char **, u_char *, int); +voidcatstr(char *, char *, char *); +voidprfield(struct field *, char *, int, mixer_ctrl_t *); +voidrdfield(int, struct field *, char *, int, char *); +__dead void usage(void); void catstr(char *p, char *q, char *out) @@ -73,14 +71,19 @@ strlcpy(out, tmp, FIELD_NAME_MAX); } -struct field * -findfield(char *name) +int +fieldcmp(const void *pa, const void *pb) { - int i; - for (i = 0; fields[i].name[0] != '\0'; i++) - if (strcmp(fields[i].name, name) == 0) - return &fields[i]; - return (0); + const struct field *a = pa, *b = pb; + return strcmp(a->name, b->name); +} + +int +fieldnamecmp(const void *pa, const void *pb) +{ + const char *name = pa; + const struct field *f = pb; + return strcmp(name, f->name); } #define e_member_name un.e.member[i].label.name @@ -241,12 +244,15 @@ int main(int argc, char **argv) { - int fd, i, j, ch, pos; + int fd, i, ch, pos; int aflag = 0, qflag = 0, vflag = 0, tflag = 0; char *file; char *sep = "="; - mixer_devinfo_t dinfo; + mixer_devinfo_t dinfo, *infos; + mixer_ctrl_t *values; int ndev; + struct field *fields, *rfields; + int nfields; if ((file = getenv("MIXERDEVICE")) == 0 || *file == '\0') file = "/dev/mixer"; @@ -331,29 +337,31 @@ } } - for (j = i = 0; i < ndev; i++) { + for (nfields = i = 0; i < ndev; i++) { if (infos[i].type != AUDIO_MIXER_CLASS && infos[i].prev == AUDIO_MIXER_LAST) { - fields[j++] = rfields[i]; + fields[nfields++] = rfields[i]; for (pos = infos[i].next; pos != AUDIO_MIXER_LAST
plug small memory leak in vfwprintf()
ok? Index: stdio/vfwprintf.c === RCS file: /cvs/src/lib/libc/stdio/vfwprintf.c,v retrieving revision 1.3 diff -u -p -r1.3 vfwprintf.c --- stdio/vfwprintf.c 28 Apr 2011 17:38:46 - 1.3 +++ stdio/vfwprintf.c 8 May 2011 23:12:00 - @@ -1051,6 +1051,8 @@ overflow: ret = -1; finish: + if (convbuf) + free(convbuf); #ifdef FLOATING_POINT if (dtoaresult) __freedtoa(dtoaresult);
Refactor wdc channel_queue malloc/initialization
Currently, wdcattach() handles initializing the channel_queue, but this is technically wrong when a single channel_queue is shared by multiple channels. Diff below refactors the malloc+init code into a single function wdc_alloc_queue(), which the bus-specific attach code can call instead of malloc(9). I also made the error messages consistent. Also, I moved the wdc_xfer_pool init code here, and dropped the splbio() 'locking' as it doesn't make any sense here. The pool initialization still isn't safe against concurrent execution, but it'll go away completely once wdc is converted to atascsi. I've sanity checked this on qemu. Tests on real life wdc/pciide systems would be appreciated though. Shouldn't have any functional changes whatsoever. ok? Index: arch/landisk/dev/wdc_obio.c === RCS file: /home/mdempsky/anoncvs/cvs/src/sys/arch/landisk/dev/wdc_obio.c,v retrieving revision 1.3 diff -u -p -r1.3 wdc_obio.c --- arch/landisk/dev/wdc_obio.c 26 Jun 2008 05:42:11 - 1.3 +++ arch/landisk/dev/wdc_obio.c 8 May 2011 21:13:29 - @@ -134,10 +134,9 @@ wdc_obio_attach(struct device *parent, s chp->channel = 0; chp->wdc = &sc->sc_wdcdev; - chp->ch_queue = malloc(sizeof(struct channel_queue), M_DEVBUF, - M_NOWAIT); + chp->ch_queue = wdc_alloc_queue(); if (chp->ch_queue == NULL) { - printf("%s: can't allocate memory for command queue\n", + printf("%s: cannot allocate channel queue\n", self->dv_xname); obio_intr_disestablish(sc->sc_ih); return; Index: arch/macppc/dev/wdc_obio.c === RCS file: /home/mdempsky/anoncvs/cvs/src/sys/arch/macppc/dev/wdc_obio.c,v retrieving revision 1.28 diff -u -p -r1.28 wdc_obio.c --- arch/macppc/dev/wdc_obio.c 29 Aug 2010 23:06:53 - 1.28 +++ arch/macppc/dev/wdc_obio.c 8 May 2011 21:13:29 - @@ -217,10 +217,9 @@ wdc_obio_attach(struct device *parent, s chp->channel = 0; chp->wdc = &sc->sc_wdcdev; - chp->ch_queue = malloc(sizeof(struct channel_queue), M_DEVBUF, - M_NOWAIT); + chp->ch_queue = wdc_alloc_queue(); if (chp->ch_queue == NULL) { - printf("%s: can't allocate memory for command queue", + printf("%s: cannot allocate channel queue", sc->sc_wdcdev.sc_dev.dv_xname); return; } Index: arch/palm/dev/palm_hdd.c === RCS file: /home/mdempsky/anoncvs/cvs/src/sys/arch/palm/dev/palm_hdd.c,v retrieving revision 1.2 diff -u -p -r1.2 palm_hdd.c --- arch/palm/dev/palm_hdd.c9 Sep 2009 11:30:56 - 1.2 +++ arch/palm/dev/palm_hdd.c8 May 2011 21:13:29 - @@ -88,7 +88,7 @@ void palm_hdd_attach(struct device *pare chp->channel = 0; chp->wdc = &sc->sc_wdcdev; - chp->ch_queue = malloc(sizeof(struct channel_queue), M_DEVBUF, M_NOWAIT); + chp->ch_queue = wdc_alloc_queue(); printf("\n"); Index: arch/socppc/dev/wdc_mainbus.c === RCS file: /home/mdempsky/anoncvs/cvs/src/sys/arch/socppc/dev/wdc_mainbus.c,v retrieving revision 1.1 diff -u -p -r1.1 wdc_mainbus.c --- arch/socppc/dev/wdc_mainbus.c 6 Sep 2009 20:09:34 - 1.1 +++ arch/socppc/dev/wdc_mainbus.c 8 May 2011 21:13:29 - @@ -132,10 +132,9 @@ wdc_mainbus_attach(struct device *parent chp->channel = 0; chp->wdc = &sc->sc_wdcdev; - chp->ch_queue = malloc(sizeof(struct channel_queue), M_DEVBUF, - M_NOWAIT); + chp->ch_queue = wdc_alloc_queue(); if (chp->ch_queue == NULL) { - printf("%s: can't allocate memory for command queue\n", + printf("%s: cannot allocate channel queue\n", self->dv_xname); /* XXX disestablish interrupt */ return; Index: dev/ic/wdc.c === RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/ic/wdc.c,v retrieving revision 1.113 diff -u -p -r1.113 wdc.c --- dev/ic/wdc.c18 Apr 2011 04:16:13 - 1.113 +++ dev/ic/wdc.c8 May 2011 21:19:52 - @@ -697,12 +697,32 @@ wdcprobe(struct channel_softc *chp) return (ret_value); } +struct channel_queue * +wdc_alloc_queue(void) +{ + static int inited = 0; + struct channel_queue *queue; + + /* Initialize global data. */ + if (inited == 0) { + /* Initialize the wdc_xfer pool. */ + pool_init(&wdc_xfer_pool, sizeof(struct wdc_xfer), 0, + 0, 0, "wdcspl", NULL); + inited = 1; + } + + queue = malloc(sizeof(*queue), M_DEVBUF, M_NOWAIT); + if (queue != NULL) { + TAILQ_INIT(&queue->sc_xf
/etc/daily ROOTBACKUP duid patch
I noticed that ROOTBACKUP stopped working when I converted the /altroot fstab entry to a disklabel UID. The attached patch seems to work for me but I'm sure there's a better way. Index: src/etc/daily === RCS file: /a8v/pub/cvsroot/OpenBSD/src/etc/daily,v retrieving revision 1.71 diff -u -p -u -p -r1.71 daily --- src/etc/daily 23 Apr 2011 19:35:53 - 1.71 +++ src/etc/daily 8 May 2011 14:39:23 - @@ -94,16 +94,33 @@ fi # use it as a backup root filesystem to be updated daily. next_part "Backing up root filesystem:" while [ "X$ROOTBACKUP" = X1 ]; do - rootbak=`awk '$2 == "/altroot" && $1 ~ /^\/dev\// && $3 == "ffs" && \ - $4 ~ /xx/ \ - { print substr($1, 6) }' < /etc/fstab` - if [ -z "$rootbak" ]; then - echo "No xx ffs /altroot device found in the fstab(5)." - break + altroot=`awk '$2 == "/altroot" && $3 == "ffs" && $4 ~ /xx/ \ + { print }' < /etc/fstab` +HAS_DUID=$(echo $altroot | grep -v '^/dev/') +if [ "X$HAS_DUID" = "X" ]; then + rootbak=`echo $altroot | awk '$2 == "/altroot" && \ + $1 ~ /^\/dev\// && $3 == "ffs" && \ + $4 ~ /xx/ \ + { print substr($1, 6) }'` + if [ -z "$rootbak" ]; then + echo "No xx ffs /altroot device found in the fstab(5)." + break + fi + bakdisk=${rootbak%[a-p]} + sysctl -n hw.disknames | grep -Fqw $bakdisk || break + bakpart=${rootbak#$bakdisk} + else + duidbak=$(echo ${altroot} | cut -d\. -f1) + bakpart=$(echo ${altroot} | awk '{print $1}' | cut -d\. -f2) + bakdisk=$(sysctl -n hw.disknames | tr "," "\n" \ + | grep -Fw $duidbak | cut -d: -f1) + if [ -z "$bakdisk" ]; then + echo "No xx ffs /altroot duid found in the fstab(5)." + break + fi + rootbak="$bakdisk$bakpart" + sysctl -n hw.disknames | grep -Fqw $bakdisk || break fi - bakdisk=${rootbak%[a-p]} - sysctl -n hw.disknames | grep -Fqw $bakdisk || break - bakpart=${rootbak#$bakdisk} baksize=`disklabel $bakdisk 2>/dev/null | \ awk -v "part=$bakpart:" '$1 == part { print $2 }'` rootdev=`mount | awk '$3 == "/" && $1 ~ /^\/dev\// && $5 == "ffs" \
Re: Eliminating unused WDC_CAPABILITY_* flags
On Sat, May 07, 2011 at 09:01:19PM -0700, Matthew Dempsky wrote: > I have plans to revamp dev/ic/wdc.c, but in the mean time, I want to > make some small cleanups so the final diff is easier to follow. > > First cleanup: The HWLOCK, ATA_NOSTREAM, and ATAPI_NOSTREAM > 'capabilities' don't appear to be set by any wdc-based adapters. > They've been here since r1.1, so I think it's just cruft that can be > safely removed... right? > > (Conversely, the SATA and SINGLE_DRIVE capabilities are set by some > adapters, but don't actually do anything. I'm tempted to kill them > too out of principle, but I don't think that's necessary just yet.) > > ok? ATA_NOSTREAM and ATAPI_NOSTREAM relate to NetBSD's bus_space stream api which we discarded in favour of the 'raw' api. Both are apparently intended to be passed in as kernel options rather than set by adapter code, and are mentioned in NetBSD's isa/wdc_isa.c and a mmeye arch (?) md driver. HWLOCK is mentioned in a 1998 NetBSD commit but I can find no current trace of it. It does seem to be cruft. ok krw@. Ken > > Index: dev/ic/wdc.c > === > RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/ic/wdc.c,v > retrieving revision 1.113 > diff -u -p -r1.113 wdc.c > --- dev/ic/wdc.c 18 Apr 2011 04:16:13 - 1.113 > +++ dev/ic/wdc.c 7 May 2011 19:57:00 - > @@ -861,9 +861,6 @@ wdcstart(struct channel_softc *chp) > if ((chp->ch_flags & WDCF_IRQ_WAIT) != 0) > panic("wdcstart: channel waiting for irq"); > #endif /* DIAGNOSTIC */ > - if (chp->wdc->cap & WDC_CAPABILITY_HWLOCK) > - if (!(chp->wdc->claim_hw)(chp, 0)) > - return; > > WDCDEBUG_PRINT(("wdcstart: xfer %p channel %d drive %d\n", xfer, > chp->channel, xfer->drive), DEBUG_XFERS); > @@ -1919,7 +1916,6 @@ wdc_get_xfer(int flags) > void > wdc_free_xfer(struct channel_softc *chp, struct wdc_xfer *xfer) > { > - struct wdc_softc *wdc = chp->wdc; > int s; > > if (xfer->c_flags & C_PRIVATEXFER) { > @@ -1928,8 +1924,6 @@ wdc_free_xfer(struct channel_softc *chp, > return; > } > > - if (wdc->cap & WDC_CAPABILITY_HWLOCK) > - (*wdc->free_hw)(chp); > s = splbio(); > chp->ch_flags &= ~WDCF_ACTIVE; > TAILQ_REMOVE(&chp->ch_queue->sc_xfer, xfer, c_xferchain); > Index: dev/ic/wdcvar.h > === > RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/ic/wdcvar.h,v > retrieving revision 1.49 > diff -u -p -r1.49 wdcvar.h > --- dev/ic/wdcvar.h 18 Apr 2011 04:16:14 - 1.49 > +++ dev/ic/wdcvar.h 8 May 2011 03:10:11 - > @@ -157,9 +157,6 @@ struct wdc_softc { /* Per controller sta > #define WDC_CAPABILITY_MODE 0x0004 /* controller knows its PIO/DMA modes */ > #define WDC_CAPABILITY_DMA0x0008 /* DMA */ > #define WDC_CAPABILITY_UDMA 0x0010 /* Ultra-DMA/33 */ > -#define WDC_CAPABILITY_HWLOCK 0x0020 /* Needs to lock HW */ > -#define WDC_CAPABILITY_ATA_NOSTREAM 0x0040 /* Don't use stream funcs on ATA > */ > -#define WDC_CAPABILITY_ATAPI_NOSTREAM 0x0080 /* Don't use stream f on ATAPI > */ > #define WDC_CAPABILITY_NO_EXTRA_RESETS 0x0100 /* only reset once */ > #define WDC_CAPABILITY_PREATA 0x0200 /* ctrl can be a pre-ata one */ > #define WDC_CAPABILITY_IRQACK 0x0400 /* callback to ack interrupt */ > @@ -195,10 +192,6 @@ struct wdc_softc { /* Per controller sta > #define WDC_DMAST_NOIRQ 0x01 /* missing IRQ */ > #define WDC_DMAST_ERR0x02 /* DMA error */ > #define WDC_DMAST_UNDER 0x04 /* DMA underrun */ > - > - /* if WDC_CAPABILITY_HWLOCK set in 'cap' */ > - int (*claim_hw)(void *, int); > - void(*free_hw)(void *); > > /* if WDC_CAPABILITY_MODE set in 'cap' */ > void(*set_modes)(struct channel_softc *);
urndis(4) manpage : add Geeksphone ONE
Hello tech@, Just a tiny diff to add another supported/tested phone to the manpage of urndis(4). Denis --- Index: src/share/man/man4/urndis.4 === RCS file: /cvs/src/share/man/man4/urndis.4,v retrieving revision 1.8 diff -u -r1.8 urndis.4 --- src/share/man/man4/urndis.4 29 Apr 2011 17:04:33 - 1.8 +++ src/share/man/man4/urndis.4 8 May 2011 13:03:19 - @@ -61,6 +61,8 @@ HTC Wildfire .It Samsung Nexus S +.It +Geeksphone ONE .El .Pp The
Re: isprint() needs setlocale(); for usr.bin
On Sun, May 08, 2011 at 01:22:55PM +0200, Stefan Sperling wrote: > Setting LANG=C for system scripts makes sense to me if the default > locale is something else. I suppose their problems are exacerbated by having > implemented LC_NUMERIC and LC_TIME, which can change output of programs > like bc(1) and date(1). We don't implement those. Point being that we might want to use LC_CTYPE instead of LC_ALL in this patch after all.
Mayo 2011
[IMAGE] Newsletter 2 - Aqo I - Mayo 2011 - noveda...@rincondeluzarte.com.ar [IMAGE]Dar la bienvenida a las energmas positivas En el feng shui consideramos a su casa como un organismo viviente. ?Csmo se alimenta, es decir, csmo toma la energma un organismo vivo? A travis de los alimentos que llegan a su boca, naturalmente. Por ese motivo, la puerta de su casa es uno de los puntos mas importantes desde el punto de vista del feng shui. La puerta es la BOCA DEL CHI, que es el tirmino que usamos en el feng shui para referirnos a la energma. >> nota completa [IMAGE]Objetos transmisores de buena energma El espejo Pa Kua es uno de los smmbolos de proteccisn mas usados en el feng shui. La forma es octogonal y debe llevar los ocho smmbolos llamados trigramas distribuidos a su alrededor creando un perfecto equilibrio. Equilibra las energmas de la casa mientras que el espejo central refleja las vibraciones negativas que pueden amenazarla. Por ejemplo, si la arista de una viga apunta directamente a la puerta principal, ubique el espejo Pa Kua sobre ista, del lado de afuera y mirando hacia la arista: repelera la energma negativa y protegera su hogar. >> nota completa [IMAGE]Dirigir la energma Usted ya aprendis a atraer la energma positiva a su hogar a travis de la puerta de entrada. Sin embargo, la sabidurma del feng shui nos enseqa que la energma debe mantenerse en movimiento y nunca estancarse. Por lo tanto, esa energma debe ser de inmediato canalizada HACIA EL LOGRO DE SUS OBJETIVOS PERSONALES O FAMILIARES. Recuerde este fragmento de "Alicia en el Pams de las Maravillas" >> nota completa [IMAGE]Conservar la energma ?Qui es lo primero que ve al entrar a su hogar? Si la respuesta es "el elemento de bienvenida que coloqui " entonces esta correcto. Pero si existe una ventana o una puerta frente a Usted que le llama mas la atencisn que el "elemento de bienvenida" entonces allm hay una pirdida de energma. Corrija este problema con cortinas o colocando una planta, un biombo o algzn objeto que oculte parcialmente la puerta (o la ventana). >> nota completa [IMAGE]Conozca las piedras que corresponden a su signo del zodmaco ** Aries- 21/03 al 20/04 Fuego PIEDRAS: amatista, Agata, Granada, hematite, jaspe,Topacio Imperial, Rubm, cornalina, Kunzita. ** Tauro - 21/04 al 20/05 - Tierra PIEDRAS: Cuarzo Rosa, Aguamarina,: Amazonita, Esmeralda, Zafiro, Amatista, Topacio Azul, Rodocrosita, Turmalina. >> nota completa [IMAGE] [IMAGE] Productos Fuentes Feng-Shui con Luz Fuentes Feng-Shui sin Luz Veladores Fuentes Feng-Shui Sahumerios Importados de la India Sahumerios Nacionles Hornillos elictricos Artmculos de Feng-Shui Piedras Semipreciosas Roladas Dijes de piedras semipreciosas Roladas Piedras semipreciosas en bruto Llaveros de piedra semipreciosa Packs de 10 piedras semipreciosas Accesorios varios Musica Feng Shui recopilacisn [IMAGE] Seguinos en:Seguinos!!! [IMAGE] [IMAGE] Rincsn de Luz Artesanmas - Fabrica de fuentes de agua Feng Shui - Artesanmas Ayacucho N: 3239 entre Intendente Alvear e Intendente Ballester. San Andres - Prov. de Buenos Aires. HORARIOS: lunes a viernes de 9 A 15.30 hs TEL: (011) 4768-3054 - CEL: 153693-3067 email: i...@rincondeluzarte.com.ar - website: www.rincondeluzarte.com.ar ENVIOS A TODO EL PAIS
Re: isprint() needs setlocale(); for usr.bin
On Sun, Apr 17, 2011 at 03:52:14PM -0700, Philip Guenther wrote: > On Sun, Apr 17, 2011 at 1:56 AM, Stefan Sperling wrote: > > On Tue, Apr 05, 2011 at 12:25:37AM +0200, Stefan Sperling wrote: > >> For isprint() to work correctly in a UTF-8 locale applications must > >> set up the LC_CTYPE locale before using isprint(). > >> > >> As done for hexdump and tcpdump already. > >> > >> This diff covers all offenders in usr.bin. > > > > Todd Miller suggested using LC_ALL instead of LC_CTYPE so we don't have > > to revisit these when we add support for more categories. > > Has there been any sort of audit of how this will affect scripts > distributed with the system? No. > I seem to recall having to fix various > scripts elsewhere when Redhat started shipping with LANG=en_US.UTF-8 > set in the default shell environment, things like character ranges in > grep patterns changing behavior. The scripts didn't handle any sort > of non-C locale correctly; the change in default just made that > incredibly obvious. The quick fix is to apply the hammer and pass > LC_ALL=C, but that's overkill when all you really want is to force > LC_CTYPE=C behavior. Is this really a problem we need to be concerned about? We're far from making a UTF-8 locale the default locale, if ever. Our default locale is C, with the addition of latin1 semantics for some functions like isprint(). It has been ever since the initial citrus bits were imported in 2005. So it's already a little bit more than ASCII. > Hmm... > > export LC_CTYPE=C > [[ -n $LC_ALL ]] && export LC_COLLATE=$LC_ALL LC_TIME=$LC_ALL \ > LC_NUMERIC=$LC_ALL LC_MONETARY=$LC_ALL LC_MESSAGES=$LC_ALL > > A quick grep of /etc/*/* on a Redhat box finds *lots* of LANG=C > settings on commands. Wheee Setting LANG=C for system scripts makes sense to me if the default locale is something else. I suppose their problems are exacerbated by having implemented LC_NUMERIC and LC_TIME, which can change output of programs like bc(1) and date(1). We don't implement those. Regarding LC_CTYPE, properties of characters in the range scripts care about remain the same in C, ISO8859-1, and UTF-8 locales. In fact, the UTF-8 locale is now stricter than our default locale because it does not even consider single-byte characters above 0x7f valid, just like C probably should.
Re: Synaptics touchpad
Hi again, I find the mouse emulation code for synaptics touch pads in your patch really weird. I've tried to understand what it does, and why it behaves badly for me on the first tap (move the pointer in the upper right direction every time), but I fail to understand the logic. So I've written a different code which produces better results and is simpler to understand. It computes relative motion events after the 2nd one, and sends any event with relative motion or button state changes. This is a diff against the pms.c resulting of your previous patch to tech@ --- pms.c.asSun May 8 10:49:02 2011 +++ pms.c Sun May 8 11:14:05 2011 @@ -73,11 +73,10 @@ /* Compat mode */ int wsmode; int old_x, old_y; + u_int old_buttons; int count; -#define SYNAPTICS_COUNT2 #define SYNAPTICS_SCALE4 #define SYNAPTICS_PRESSURE 30 -#define SYNAPTICS_MAXSPEED 30 int dev_pt_attach; }; @@ -912,36 +911,23 @@ WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y | WSMOUSE_INPUT_ABSOLUTE_Z | WSMOUSE_INPUT_ABSOLUTE_W); } else { - if (syn->count < SYNAPTICS_COUNT) { - syn->old_x += x; - syn->old_y += y; - syn->count++; - return; + dx = dy = 0; + if (syn->count != 0) { + dx = x - syn->old_x; + dy = y - syn->old_y; + dx /= SYNAPTICS_SCALE; + dy /= SYNAPTICS_SCALE; } - - syn->old_x /= SYNAPTICS_COUNT; - syn->old_y /= SYNAPTICS_COUNT; - dx = x - syn->old_x; - dy = y - syn->old_y; - syn->old_x = (dx % SYNAPTICS_SCALE) * SYNAPTICS_COUNT; - syn->old_y = (dy % SYNAPTICS_SCALE) * SYNAPTICS_COUNT; - dx /= SYNAPTICS_SCALE; - dy /= SYNAPTICS_SCALE; - syn->count = 0; - - if (z < SYNAPTICS_PRESSURE) { - dx = dy = 0; - syn->old_x = syn->old_y = 0; + if (z < SYNAPTICS_PRESSURE) syn->count = 0; - } - - if (abs(dx) > SYNAPTICS_MAXSPEED) - dx = SYNAPTICS_MAXSPEED * dx / abs(dx); - if (abs(dy) > SYNAPTICS_MAXSPEED) - dy = SYNAPTICS_MAXSPEED * dy / abs(dy); - - wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, 0, 0, - WSMOUSE_INPUT_DELTA); + else + syn->count++; + if (dx || dy || buttons != syn->old_buttons) + wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, 0, 0, + WSMOUSE_INPUT_DELTA); + syn->old_x = x; + syn->old_y = y; + syn->old_buttons = buttons; } } -- Matthieu Herrb
Re: Synaptics touchpad
On Sun, May 08, 2011 at 06:36:46AM +0600, Alexandr Shadchin wrote: > Hi, > > Default touchpad behaves as mouse (compatible with xf86-input-mouse) > for full power need used xf86-input-synaptics. > > Please check work of touchpad in compat mode (xf86-input-mouse), > who are interested check xf86-input-synaptics. > > Driver xf86-input-synaptics need to build manually: We will provide some xserver patch in the future to automatically generate it when no xorg.conf is present and a synaptics touchpad is deteced, but in the mean time you need this sample xorg.conf fragment (which can be used alone if you don't have any xorg.conf) to enable the xf86-input-synaptics driver for the touchpad, while still allowing an external (usb or ps/2) mouse to be used with the xf86-input-mouse driver: Section "InputDevice" Identifier "Touchpad0" Driver "synaptics" Option "Device" "/dev/wsmouse0" Option "AutoServerLayout" "True" EndSection Section "InputDevice" Identifier "Mouse0" Driver "mouse" Option "Device" "/dev/wsmouse" Option "AutoServerLayout" "True" EndSection (the "Device" sections are important). If you don't explicitely setup the xf86-input-synaptics driver in xorg.conf, the xf86-input-mouse driver will still handle all wsmouse(4) input events, and you won't benifit of any enhanced features for the synaptics driver. when a synaptics touchpad is detected by the pms(4) driver, it will enable all the synaptics firmware features, but still provide a standard relative pointer to wsmouse(4) until a specific ioctl() is issued to switch to the native synaptics protocol. This ioctl is used by the xf86-input-synaptics driver to unleash the extra features. -- Matthieu Herrb
Re: typo in icmp6(4)
On Sat, May 07, 2011 at 09:29:21PM +0200, Andreas Bartelt wrote: > Hello, > > I've noticed a typo in the icmp6(4) man page regarding icmp6 type 4 code > 2. Diff is attached. > i've looked at the rfc, and {net,free}bsd man pages, and am clueless. would any other developer like to comment on this? jmc > According to the (informational) RFC 4890 this kind of icmp6 message > must not be dropped for the correct functioning of IPv6. Is there a key > word planned for this icmp6 code which could be used in PF? > > Best regards, > Andreas > Index: share/man/man4/icmp6.4 > === > RCS file: /usr/cvsync/cvs/src/share/man/man4/icmp6.4,v > retrieving revision 1.23 > diff -u -r1.23 icmp6.4 > --- share/man/man4/icmp6.48 Dec 2009 07:57:57 - 1.23 > +++ share/man/man4/icmp6.47 May 2011 19:05:11 - > @@ -126,7 +126,7 @@ > .It 1 Ta reassemb Ta timex Ta "Time exceeded in reassembly" > .It 0 Ta badhead Ta paramprob Ta "Erroneous header field" > .It 1 Ta nxthdr Ta paramprob Ta "Unrecognized next header" > -.It 2 Ta "" Ta redir Ta "Unrecognized option" > +.It 2 Ta "" Ta paramprob Ta "Unrecognized option" > .It 0 Ta redironlink Ta redir Ta "Redirection to on-link node" > .It 1 Ta redirrouter Ta redir Ta "Redirection to better router" > .El
Re: malloc: memory leak instrumentation
On Fri, May 06, 2011 at 07:53:01AM +0200, Otto Moerbeek wrote: > On Thu, May 05, 2011 at 08:21:25PM +0200, Otto Moerbeek wrote: > > > On Thu, May 05, 2011 at 02:29:39PM +0200, Otto Moerbeek wrote: > > > > > Hi, > > > > > > Now that the latest chunk scan optimization diff is committed, it's > > > time to present a malloc feature diff. > > > > > > This diff adds instrumentation to a MALLOC_STATS enabled malloc.c to > > > detect and report memory leaks, including the address of the code that > > > allocated memory that was not freed. With the help of gdb, you can > > > translate this address into a source file location. > > > > > > For instructions and to show some of the possibilities, check > > > > > > http://www.drijf.net/malloc/ > > > > > > Diff also below. It was good fun working on this, and I hope you'll > > > enjoy it as well. > > > > > > Note that this diff a a bit bigger than strictly needed, I moved the > > > stats reporting code to the bottom of the file. Something I wanted to > > > do for a long time. > > > > Updated diff. Kent R. Spillner spotted a glitch that caused a (ironly!) > > memory leak in the reporting code, > > > > And another update. I'm now using the region field to store the code > address for chunk 0 too. This saves some meta data space. YAU (yet another update). No actual code changes, but I did a seperate commit that moved the MALLOC_STATS bits to the bottom of the file. That makes this diff much more pleasent to read. -Otto Index: malloc.c === RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v retrieving revision 1.131 diff -u -p -r1.131 malloc.c --- malloc.c8 May 2011 07:08:13 - 1.131 +++ malloc.c8 May 2011 07:12:03 - @@ -43,6 +43,7 @@ #include #ifdef MALLOC_STATS +#include #include #endif @@ -94,6 +95,9 @@ struct region_info { void *p;/* page; low bits used to mark chunks */ uintptr_t size; /* size for pages, or chunk_info pointer */ +#ifdef MALLOC_STATS + void *f;/* where allocated from */ +#endif }; LIST_HEAD(chunk_head, chunk_info); @@ -125,9 +129,11 @@ struct dir_info { size_t cheap_reallocs; #define STATS_INC(x) ((x)++) #define STATS_ZERO(x) ((x) = 0) +#define STATS_SETF(x,y) ((x)->f = (y)) #else #define STATS_INC(x) /* nothing */ #define STATS_ZERO(x) /* nothing */ +#define STATS_SETF(x,y)/* nothing */ #endif /* MALLOC_STATS */ u_int32_t canary2; }; @@ -195,6 +201,9 @@ extern char *__progname; #ifdef MALLOC_STATS void malloc_dump(int); static void malloc_exit(void); +#define CALLER __builtin_return_address(0) +#else +#define CALLER NULL #endif /* low bits of r->p determine size: 0 means >= page size and p->size holding @@ -696,7 +705,7 @@ alloc_chunk_info(struct dir_info *d) } static int -insert(struct dir_info *d, void *p, size_t sz) +insert(struct dir_info *d, void *p, size_t sz, void *f) { size_t index; size_t mask; @@ -717,6 +726,9 @@ insert(struct dir_info *d, void *p, size } d->r[index].p = p; d->r[index].size = sz; +#ifdef MALLOC_STATS + d->r[index].f = f; +#endif d->regions_free--; return 0; } @@ -839,7 +851,7 @@ omalloc_make_chunks(struct dir_info *d, if ((uintptr_t)pp & bits) wrterror("pp & bits", pp); - insert(d, (void *)((uintptr_t)pp | bits), (uintptr_t)bp); + insert(d, (void *)((uintptr_t)pp | bits), (uintptr_t)bp, NULL); return bp; } @@ -848,7 +860,7 @@ omalloc_make_chunks(struct dir_info *d, * Allocate a chunk */ static void * -malloc_bytes(struct dir_info *d, size_t size) +malloc_bytes(struct dir_info *d, size_t size, void *f) { int i, j; size_t k; @@ -908,6 +920,12 @@ malloc_bytes(struct dir_info *d, size_t i = 0; } d->chunk_start += i + 1; +#ifdef MALLOC_STATS + if (i == 0) { + struct region_info *r = find(d, bp->page); + r->f = f; + } +#endif *lp ^= u; @@ -980,7 +998,7 @@ free_bytes(struct dir_info *d, struct re static void * -omalloc(size_t sz, int zero_fill) +omalloc(size_t sz, int zero_fill, void *f) { void *p; size_t psz; @@ -997,7 +1015,7 @@ omalloc(size_t sz, int zero_fill) errno = ENOMEM; return NULL; } - if (insert(g_pool, p, sz)) { + if (insert(g_pool, p, sz, f)) { unmap(g_pool, p, psz); errno = ENOMEM; return NULL; @@ -1034,7 +1052,7 @@ omalloc(size_t sz, int zero_fill) } else { /* takes care of SOME_JUNK */ - p = malloc_bytes(g_pool, sz); + p = malloc_bytes(g_pool, sz, f); if (zero_fill && p != NULL && sz > 0)