crease the cpu frequency until all the
cpu are busy - so for a 'mostly single-threaded' application this
doesn't happen and the cpus stays at 1.6GHz instead of increasing
to 3.4GHz.
Running 'while :; do :; done' once for eacg cpu makes the program
run faster!
David
--
David Laight: da...@l8s.co.uk
tart fixing them!
(Like getting ^C to work for windows console programs in mintty windows.)
David
--
David Laight: da...@l8s.co.uk
[] the
generated code is likely to be better if 't' is evaluated before
the write to out[1].
David
--
David Laight: da...@l8s.co.uk
On Thu, Feb 28, 2013 at 01:53:25PM -0800, Andy Lutomirski wrote:
> > O_DENYMAND - to switch on/off three flags above.
>
> O_DENYMAND doesn't deny anything. Would a name like O_RESPECT_DENY be
> better?
Possibly rename to O_CHECK_DENY ?
David
--
David Laight: da...@l8s.co.uk
to can't be aliased
by the memory that is read.
If aliasing is possible the compiler has sequence the code to
ensure the writes and reads happen in the correct order.
That function probably has too many live values for the normal
registers - so some values will get flushed to stack.
SSE might be better.
David
--
David Laight: da...@l8s.co.uk
will be 32bit aligned unless the structure is 'packed'
(or similar).
David
--
David Laight: da...@l8s.co.uk
s the others
because the windows C compiler manages to obtain exclusive access
to the source files - stopping the other systems from reading them.
David
--
David Laight: da...@l8s.co.uk
K we only see 0xA3 (pound sterling) - but it can crop up
anywhere - and causes my mail program (which, for some reason I
don't understand) assumes UTF-8 do drop core responsing to mails!
David
--
David Laight: da...@l8s.co.uk
ckrealign in case
they happen to use SSE2 instrctions.
It is all a pig's breakfast.
David
--
David Laight: da...@l8s.co.uk
ecific - but I am counting every instruction
in that function.
(This is a MIPS-like embedded cpu.)
David
--
David Laight: da...@l8s.co.uk
gcc
tries to align on-stack double and long-long items but not realign the
stack in order to do so.
We've just gone through a series of hoops in NetBSD trying to fix
gcc to generate code that doesn't assume 16 byte aligned stack and
doesn't fault internally.
David
--
David Laight: da...@l8s.co.uk
gns the stack when main (strictly _start) is called,
but anything not compiled by gcc (or compiled with other options)
can lose that alignment.
If you request 32 byte alignment for the save area, (recent enough) gcc
will align the stack before allocating the locals.
David
--
David Laight: da...@l8s.co.uk
t malloc() should return 16 byte aligned memory.
But I bet some i386 ones don't.
Especially since gcc is quite capable of suddently using the
SSE2 (etc) instructions that require such alignment.
David
--
David Laight: da...@l8s.co.uk
her
than being a pointer to an INT, but that means that having both
INT_PTR and LONG_PTR is silly.
Having an extra typedef for 'foo *' is really silly, amongst other
things you can't convert it to 'const foo *' (only to 'foo * const').
David
--
David Laight: da...@l8s.co.uk
On Wed, Oct 10, 2012 at 10:42:53AM +0200, joerg-cyril.hoe...@t-systems.com
wrote:
> Hi,
>
> David Laight wrote:
>
> >Better to code as:
> >status = wmm->dwStatus;
> >if (...)
> Incidentally, that's what I did tonight in patch 20/25 try 2.
gisters - so instead of spilling 'status'
to stack, it would re-read it.
With gcc you can force it to only to one read by adding:
asm volatile("":::"memory");
before the first if.
The "memory" constraint of the asm statement tells gcc that it might
change any memory location - thus acting as a barrier.
The only portable way is with volatile.
David
--
David Laight: da...@l8s.co.uk
een processed in order to know where to find the next argument.
David
--
David Laight: da...@l8s.co.uk
be allowed.
I couldn't find anything that looked like 'offsetof' that would generate
a real compile-time constant.
I can't remember whether it is 'constant enough' to let you do:
static char fubar[offsetof(struct a, b[3])];
David
--
David Laight: da...@l8s.co.uk
(((_x) & 0xff00) << 8) | \
> + (((_x) & 0xff) >> 8) |\
> + (((_x) & 0xff00) >> 24) )
You shouldn't really define macros that expand their arguments
multiple times.
David
--
David Laight: da...@l8s.co.uk
of toupper() isn't char, the value must be cast to
'unsigned char' (or the pointer to 'unsigned char *').
David
--
David Laight: da...@l8s.co.uk
On Tue, May 08, 2012 at 12:03:52PM +0200, Damjan Jovanovic wrote:
> On Tue, May 8, 2012 at 11:40 AM, David Laight wrote:
> > Does wine support running of 16bit windows apps?
> > If so does it rely on the underlying OS having support
> > for 'virtual 8086 emulation
Does wine support running of 16bit windows apps?
If so does it rely on the underlying OS having support
for 'virtual 8086 emulation'?
I'm thinking of removing the VM86 support from NetBSD,
and wine is about the only likley user.
David
--
David Laight: da...@l8s.co.uk
> to make really sure you get 0 or 1, you never know what might happen ;-)
But see also http://www.hermetic.ch/cal_stud/cal_art.html for some
info about which years were/are actually leap years ...
David
--
David Laight: da...@l8s.co.uk
ntf, but a function that took a list of
pointers followed by a NULL - so I copied them into an on-stack array.
David
--
David Laight: da...@l8s.co.uk
ters, and the first few FP args in FP regs (regardless
of the order of the parameters), the va_list data has to remember
which register args have been processed.
This is all somewhat tricky! and makes support for printf's argument
order selection stuff extremely difficult to write!
David
--
David Laight: da...@l8s.co.uk
actually hide
other issues (like accidentally casting a pointer type).
David
--
David Laight: da...@l8s.co.uk
> > -errno = -ret;
> > +errno = ret;
>
> syscall is supposed to take care of errno.
I'm also not at all sure of the portability of using syscall() in
application code.
What happens when you try to run the above on anything other than Linux?
(Eg aone of the BSDs)
David
--
David Laight: da...@l8s.co.uk
; >
> > 'debug_children' would be a better name.
>
> also
> unsigned intfoo:1;
> please. (int foo:1 works, but is semidefined only ;)
Why the bitfield anyway?
Unless you are allocating a lot of copies of the structure
it is likely to generate more code than the saved memory.
David
--
David Laight: da...@l8s.co.uk
()) is a bad idea
as a kernel 'call through NULL ptr' can be used to escalate
privs.
David
--
David Laight: da...@l8s.co.uk
On Mon, Aug 29, 2011 at 06:43:41PM -0700, Alan W. Irwin wrote:
> double x;
> while(fscanf(stdin, " %le ", &x) == 1)
You are using the wrong format, %le is for 'long double', this will
probably overwrite too much data.
David
--
David Laight: da...@l8s.co.uk
where I observed "(null)" for NULL.
> (Or is that really glibc only?)
Probably glibc, solaris was one of the first unix (I saw) to fault
on accesses to address zero and certainly the current solaris libc
will fault.
David
--
David Laight: da...@l8s.co.uk
so bash adds a slash during autocomplete, that's ok.
> gcc itself can also deal with a trailing / for -B, it's kinda
> suprising, if this breaks in winegcc.
bash has 'broken' many things by doing that.
Traditionally directory paths wouldn't be expected to have a trailing '/'.
David
--
David Laight: da...@l8s.co.uk
.
> union field_order { int an_int; int a_bit:1 } test;
> test.an_int=0;
> test.a_bit=1;
...
There are 4 likely values for test.an_int (1, 0x80, 0x8000, 0x0100),
and all might be generated regardless of the system endianness.
David
--
David Laight: da...@l8s.co.uk
ave instructions
for reading and writing memory with byteswap, but no instruction for
swapping a register. Newer gccs can be taught how to use these instructions
for specific source sequences.
David
--
David Laight: da...@l8s.co.uk
ther one of
> > first 2.
> > - seek back where we were
> >
> > I think this would also fix fake_dot_dot + single_entry case. What do you
> > think?
>
> That could probably be made to work, yes.
Remember that you can only seek to the offsets returned by the OS.
Directory offsets aren't necessarily byte offsets.
(They may be 64bit values even for small directories.)
David
--
David Laight: da...@l8s.co.uk
list;' is a pointer to an array of pointers
to address buffers (defined as char) - not a pointer to an array of addresses.
IIRC the 'something' will be an IPv4 address - which might
be held as a 32 bit quantity rather that an array of char.
But nowhere should you cast the 32bit int (DWORD) to/from a pointer type.
David
--
David Laight: da...@l8s.co.uk
hostbyname only returns IPv4 addresses, i.e.
> ones that can fit in a DWORD.
That doesn't sound like a problem that would give that warning.
David
--
David Laight: da...@l8s.co.uk
> -strncpy(buff, "x", sizeof(buff)/sizeof(CHAR));
> > +strcpy(buff, "x");
What is wrong with:
buff[0] = 'x';
buff[1] = 0;
David
--
David Laight: da...@l8s.co.uk
a requirement of the C language, there are many implemenations
which will fault.
David
--
David Laight: da...@l8s.co.uk
0x, "Default background color reported as
> > 0x%.8x\n", crColor);
> >
>
> ~0 looks better here imo.
Rather ~0u
The 0x should be 0xu
David
--
David Laight: da...@l8s.co.uk
oaded into an FP register.
David
--
David Laight: da...@l8s.co.uk
long ago as I would have found it useful
> for front end user interfaces.
It is worth remembering that an elf program's 'main' can be in a
shared object! This mightmake it easier to write a stub binary
that effectively make a .so executable.
Sort of depends on what the guy way tring to do...
David
--
David Laight: da...@l8s.co.uk
'
and the 'cmove'.
ffs would probably execute faster with a forwards conditional branch
(predicted not taken) in the 'return -1' path.
David
--
David Laight: da...@l8s.co.uk
it is likely to be absent (unless you are doing
a lot of lookups together).
David
--
David Laight: da...@l8s.co.uk
instruction on most x86 processors!
You'd also get a gain from getting the 'if (x == 0)' statically predicted
correctly (probably for not zero) - that is also likely to be large.
David
--
David Laight: da...@l8s.co.uk
0;
}
Which works provided that there are only 2 encoding patterns for zero.
David
--
David Laight: da...@l8s.co.uk
avoid that gap (the main difference between aLaw anf uLaw audio).
It also requires that the compiler use stricter data aliasing rules
than are required by the C standard.
Using a union is ok (but you must write and read a union variable,
not just cast to a union type.
David
--
David Laight: da...@l8s.co.uk
ng at a printout
on fanfold paper,
David
--
David Laight: da...@l8s.co.uk
some
definition of the word 'properly') most noticably cygwin on windoes 7.
David
--
David Laight: da...@l8s.co.uk
.
Better still "${WINEPREFIX:-${HOME:?}/.wine}/dosdevices/c:/Program Files"
which will generate an error if HOME isn't set.
David
--
David Laight: da...@l8s.co.uk
requires an absolute path. This is a
> common trick used for locating interpreters for e.g. Python as well.
It does depend on 'env' being installed in a standard place!
It is also rather a side effect of env's real purpose - sanitising
the environment.
David
--
David Laight: da...@l8s.co.uk
he library names are shown in the NEEDED entries (the value comes from
the soname property of the library found when linking the program.
This is usually just foo.so, but can contain directory names.
David
--
David Laight: da...@l8s.co.uk
al;
> > - __ms_va_list valist;
> > + __ms_va_list valist = xvalist;
>
> You can't copy a valist. This needs to be integrated properly with the
> other printf functions.
Well, you can if you can find a va_copy() function .
David
--
David Laight: da...@l8s.co.uk
y()
does and can make assumptions based on the actual structure type
involved. This can cause extreme grief if you try to copy from a
misaligned pointer into a local variable (strictly, in valid C, you
can never get a misaligned pointer - and the compiler will use
word accesses).
David
--
David Laight: da...@l8s.co.uk
Not to mention the bloatage of using 'inline' for something that size.
David
--
David Laight: da...@l8s.co.uk
#x27;t exactly clear before, but now it's really
> impossible to follow. Please rewrite this in a way that makes sense to a
> casual reader.
Clearly it should be:
mixdev[mixnum].chans += !!mastelem + !!headelem + !!pcmelem + (micelem
&& !mastelem && !captelem);
ducks quickly ... :-)
David
--
David Laight: da...@l8s.co.uk
_string_char *this, size_t pos, size_t len)
> > {
> > -TRACE("%p %d %d\n", this, pos, len);
> > +TRACE("%p %d %d\n", this, (int)pos, (int)len);
>
> You should be casting to long, otherwise you'll potentially truncate the
> value.
In wh
- even in 64bit mode.
David
--
David Laight: da...@l8s.co.uk
David
[1] The instruction sets are different - the single byte opcodes for
inc/dec register are reallocated for other uses. So you cannot just
load 32bit code into a 64bit binary and expect anything sane to happen.
--
David Laight: da...@l8s.co.uk
e user space mapping of address 0 some time
in the near future - it does have problems with the compatibility code
for other unix system binariess though (I can't remember which ones,
compat-ultrix might be the one).
David
--
David Laight: da...@l8s.co.uk
(s).
It is also quite simple to generate sine waves without any trig.
David
--
David Laight: da...@l8s.co.uk
array_member[expression])
and this now reported as illegal by gcc unless 'espression' is a compile
time constant :-(
David
--
David Laight: da...@l8s.co.uk
0' before the strtol() call.
strtol() will only change errno if there is a numeric overflow.
In the overflow cases the return value will be LONG_MIN or LONG_MAX and
errno is set to ERANGE. No other errno values should appear.
I thought that the only 'size' difference is that 64bit windows has a
32bit long ?
So values outside 32bits need truncating and ERANGE set ??
David
--
David Laight: da...@l8s.co.uk
On Sat, Aug 15, 2009 at 07:37:12PM +0200, Henri Verbeet wrote:
> 2009/8/15 Rico Sch?ller :
> > +static inline void parse_annotation(const char **ptr, unsigned int count)
^^
And there is no reason to inline something this size
David
--
David Laight: da...@l8s.co.uk
On Fri, Jul 17, 2009 at 07:27:11PM -0500, John Klehm wrote:
>
> Oops I guess SHGetFolderPath is more portable (win95 and up)
It is just a pain getting the right include file and library,
especially on win2k with oldish versions of visual C.
David
--
David Laight: da...@l8s.co.uk
return anything sensible for an inode number.
David
--
David Laight: da...@l8s.co.uk
e not looked at what wine is doing here, but the value returned by
lseek() for directories isn't necessarily a byte offset.
David
--
David Laight: da...@l8s.co.uk
ke GCC be able to
> target Win16 (not likely) or write a whole new compiler toolchain to target
> Win16/DOS, there really isn't anything else left to use.
Will 'Bruce's C Compiler' target DOS/Win 16 ?
David
--
David Laight: da...@l8s.co.uk
r/wrapper
> (e.g., current win16 libs are actually compiled as 32bit).
NetBSD (at least) has VM86 support in the kernel, however I don't know
if it still works :-)
David
--
David Laight: da...@l8s.co.uk
In any case the above example is doomed to failure.
I don't expect that windows defines which thread runs first.
And on a multi-processor system they are likely to both run.
So I'd guess that warpatch.bin or broken.
David
--
David Laight: da...@l8s.co.uk
another issue. Does anything run at all on NetBSD?
A lot of things run on NetBSD :-)
Which version of NetBSD are you testing on?
NetBSD 4 uses an m:n thread library, so there is no guarantee which system
LWP will run which user thread (it will change dynamically).
(In particular when one user thread wakes another, it can be pre-empted
entirely in userspace.)
NetBSD 5 uses a 1:1 thread library due to intractable problems on SMP
systems.
David
--
David Laight: da...@l8s.co.uk
d should be done.
Not in any shells I've fixed.
There is no need for the shell itself to pre-process process input/output.
There are no control sequences for the shell.
(^C etc are detected by the kernel line-discipline code and sent as signals
to the session leader.)
David
--
David Laight: da...@l8s.co.uk
etect and code for.
David
--
David Laight: da...@l8s.co.uk
e between 'int'
> and 'long', and thus would likely be so upset if 'long' where ever to
> change size that they might commit suicide in droves. So they decided
> that 'long' would remain 32bits.
Not only Windows application programmers
What
; >#else
> >V_I8(&vt) = nan_magic_pattern;
> >#endif
> >
>
> The problem is that nan_magic_pattern would have to be 8 bytes and AFAIK
> there is no portable way to do it without ugly casts like in attached patch.
And that break C's 'strict al
using
a non-constant format string.
Quite possibly adding a global variable whose value is a
always zero to the format string is enough.
David
--
David Laight: [EMAIL PROTECTED]
iaTypeSize < 2) ? 1 : dwMediaTypeSize / 2
which is unlikely to have the desired effect!
David
--
David Laight: [EMAIL PROTECTED]
rong type.
David
--
David Laight: [EMAIL PROTECTED]
reat filenames as byte-strings, this is 100% reasonable :-)
Any conversion to glygps isn't a filesyatem operation.
David
--
David Laight: [EMAIL PROTECTED]
em) - (unsigned int)(&((type *)0)->field)))
> > +((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field)))
How about:
((type *)((char *)(elem) - ((char *)(&((type *)0)->field) - (char *)0)))
David
--
David Laight: [EMAIL PROTECTED]
r *) 0.
(char *)0 is bad, 0 is ok, as is (void *)0
>
> There's no heuristic involved here, the assignment is clearly to a
> pointer, and 0 is a perfectly valid null pointer, no cast is needed.
As is 1-1, or any other compile time integer expression with a numeric
vaule of zero.
David
--
David Laight: [EMAIL PROTECTED]
printf(file, "%s", arg) into fputs(arg, file).
Discovered on a semi-embedded system which had fprintf, but not fputs :-)
David
--
David Laight: [EMAIL PROTECTED]
s of the union are 'void *' and 'intptr_t'
you can't assume that a value written to one field of the union
can be immediately read from the other.
David
--
David Laight: [EMAIL PROTECTED]
3.
Not only commercial companies who may not have been obeying the
general spirit of the GPL, but also people writing software that
is BSD licensed are worried about having GPL3 utilities
included in a software release, and having GPL3 source residing in
the local CVS tree.
David
--
David Laight: [EMAIL PROTECTED]
sequence that caused a terminal to send back its identification sequence.
Running 'ls' caused keyboard input
David
--
David Laight: [EMAIL PROTECTED]
On Sun, Jul 01, 2007 at 02:57:58AM +0200, J?r?me Gardou wrote:
>
> All I know is that wine shouldn't use * and ? , since it is used in wildcards
> on both Unix and Windows !
But they are not illegal in unix filenames.
Only 2 byte values cannot be used, 0 and '/'.
nd can be space/tab anyway).
David
--
David Laight: [EMAIL PROTECTED]
or
> UINT32
The C99 type is 'uint32_t' - and should be defined by inttypes.h
David
--
David Laight: [EMAIL PROTECTED]
ion, which part of the mbr sector do the games
think they can access? Especially for write ?
Having written the mbr code that NetBSD uses - which could validly be
in sector zero of the boot disk of a windows systesm - I'm not at all
certain there any bytes that can usefully be used.
ata wouldn't fit (not the number of bytes
that would have been output).
2) _snprintf() doesn't always NUL terminate the output! In particular
_snprintf(buf, 2, "ab" ) will set buf[0] = 'a', buf[1] = 'b', and
return 2.
Almost certainly not w
char xxx[...]
...
printf("%.*s", sizeof xxx, xxx);
since the argument for '*' has to be of type 'int'.
Here you have to have the (int) cast, directly of maybe via:
#define isizeof (void)sizeof
David
--
David Laight: [EMAIL PROTECTED]
is likely to give a 'computed value not used' warning instead.
What you really don't want to do is allow casts from 'int' to 'foo *'.
After all casting from 'foo *' to 'bar *' is easy.
David
--
David Laight: [EMAIL PROTECTED]
== ch) return __deconst(str); } while (*str++);
return 0;
}
David
--
David Laight: [EMAIL PROTECTED]
f course, your filesystem is samba-mounted from a linux box,
when PCH tends to cause internal compiler errors.
David
--
David Laight: [EMAIL PROTECTED]
,(%esi+%ecx-4)
mov (%edi+%ecx-4),%eax
shrl $2, %ecx
rep movsl
should be better given large enough %ecx
David
--
David Laight: [EMAIL PROTECTED]
ans to make this so?
>
> Wine is meant to work on NetBSD, however chances are the build has broken
> over time due to lack of testing. I suggest you try building it and see
> what happens.
There has been a working version in pkgsrc, but I suspect it is old.
David
--
David Laight: [EMAIL PROTECTED], [EMAIL PROTECTED]
(buff, 3, "ab" ) returns 2, buff = "ab<0>"
_snprintf(buff, 3, "abcd" ) returns -1, buff = "ab<0>"
but:
_snprintf(buff, 3, "abc" ) returns 3, buff = "abc"
without NUL terminating the string.
Do you replicate that?
David
--
David Laight: [EMAIL PROTECTED]
pe, ptr) ((type *)discard_const(ptr))
Or:
static inline void *deconst(const void *p)
{
return ((const char *)p - (const char *)0) + (char *)0;
}
David
--
David Laight: [EMAIL PROTECTED]
y generating unique inode numbers.
(There is no answer to the problem though)
David
--
David Laight: [EMAIL PROTECTED]
e semantics
I think you will find that solaris uses kernel LWPs for threads.
If you give ps the correct incantation it wil show them.
David
--
David Laight: [EMAIL PROTECTED]
1 - 100 of 109 matches
Mail list logo