Re: [PATCH v16] kern: simple futex for gnumach

2014-01-17 Thread Marin Ramesa
On 01/17/2014 03:56:39 PM, Justus Winter wrote: Sounds promising, if they are in a shape to be presented, please publish these patches somewhere. I'll polish the quick hacks for libpthread and send it to the list. Also, did you try some more complex programs? Not yet. I'm looking for a prog

[PATCH v16] kern: simple futex for gnumach

2014-01-17 Thread Marin Ramesa
t, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Marin Ramesa + */ + +/* + * Fast userspace locking. + */ + +#include +#include +#include +#include +#include +#include +#include + +struct futex { + queue_chain_t chain; /* Futex cha

Re: [PATCH v15] kern: simple futex for gnumach

2014-01-15 Thread Marin Ramesa
On 01/15/2014 10:56:25 AM, Justus Winter wrote: > I tested a simple userspace mutex based on this and multiple futexes, > all tests passed. Could you put that somewhere? I still have so little "context", I'd like to see how futexe are used in a mutex implementation. Here's what I used: #inc

[PATCH v15] kern: simple futex for gnumach

2014-01-14 Thread Marin Ramesa
ense + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Marin Ramesa + */ + +/* + * Fast userspace locking. + */ + +#include +#include +#include +#include +#include +#include +#include + +struct futex

Re: [PATCH v14] kern: simple futex for gnumach

2014-01-13 Thread Marin Ramesa
On 01/13/2014 06:28:44 PM, Richard Braun wrote: On Mon, Jan 13, 2014 at 03:38:19PM +0100, Marin Ramesa wrote: > Fixed a bug in private wakeups by calling ipc_entry_alloc_name(). > > This is the last version as everything works now. *Sigh* You didn't understand my comment mention

[PATCH v14] kern: simple futex for gnumach

2014-01-13 Thread Marin Ramesa
ARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Mari

[PATCH v13] kern: simple futex for gnumach

2014-01-12 Thread Marin Ramesa
ceived a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Marin Ramesa + */ + +/* + * Fast userspace locking + * + */ + +#include +#include +#include +#include

[RFC] kern: simple futex for gnumach (version 12)

2014-01-11 Thread Marin Ramesa
the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Marin Ramesa + */ + +/* + * Fast

Re: [RFC] kern: simple futex for gnumach (version 11)

2014-01-09 Thread Marin Ramesa
On 01/09/2014 05:36:18 PM, Diego Nieto Cid wrote: Finally, why is pfutexes an array? You are always using it's last element (that is if the ARRAY_SIZE macro worked as intended). I was actually not using it, so I didn't notice the bug while testing. Thanks for the comments, the code has been cor

Re: [RFC] kern: simple futex for gnumach (version 11)

2014-01-09 Thread Marin Ramesa
On 01/10/2014 01:59:55 AM, Richard Braun wrote: On Thu, Jan 09, 2014 at 09:51:51PM +0100, Marin Ramesa wrote: > On 01/09/2014 05:52:21 PM, Richard Braun wrote: > >On Thu, Jan 09, 2014 at 05:06:09PM +0100, Marin Ramesa wrote: > >> Shouldn't the compare be atomic. Maybe

Re: [RFC] kern: simple futex for gnumach (version 11)

2014-01-09 Thread Marin Ramesa
On 01/09/2014 05:52:21 PM, Richard Braun wrote: On Thu, Jan 09, 2014 at 05:06:09PM +0100, Marin Ramesa wrote: > Shouldn't the compare be atomic. Maybe I don't understand what > atomic really > means but the GCC manual says this function is. Or is it enough to > hold t

Re: [RFC] kern: simple futex for gnumach (version 11)

2014-01-09 Thread Marin Ramesa
On 01/09/2014 03:45:35 PM, Richard Braun wrote: > +/* TODO Should be per-task. */ > +static struct futex *pfutexes; Most locks are private, so yes, do work on that too. I actually did not implement this because I don't know how. How to make a variable visible only and private to a task? I trie

[RFC] kern: simple futex for gnumach (version 11)

2014-01-08 Thread Marin Ramesa
02139, USA. + * + * Author: Marin Ramesa + */ + +/* + * Fast userspace locking + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) + +struct futex { + + /* Futex node in the futex tree. */ +

Re: [RFC] kern: simple futex for gnumach (version 10)

2014-01-07 Thread Marin Ramesa
On 01/06/2014 03:00:35 PM, Richard Braun wrote: We also need to make sure nothing bad happens to an (object, offset) pair when, say, copy-on-write is performed by the VM system... I'll add a check_consistency() routine to futex_wake() which repeats the vm_map_lookup(). I'll use a sum of object

[RFC] kern: simple futex for gnumach (version 10)

2014-01-05 Thread Marin Ramesa
of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Marin Ramesa + */ + +/* + * Fast userspace locking + * + */ + +#include +#include +#include +#include +#include +#include

[RFC] kern: simple futex for gnumach (version 9)

2014-01-04 Thread Marin Ramesa
, MA 02139, USA. + * + * Author: Marin Ramesa + */ + +/* + * Fast userspace locking + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * When color of the node is red, parent of the node is the futex address, left child is + * the futex waiter offset

Re: [RFC] kern: simple futex for gnumach (version 8)

2013-12-31 Thread Marin Ramesa
On 12/31/2013 04:26:01 PM, Richard Braun wrote: On Sun, Dec 29, 2013 at 09:44:51PM +0100, Marin Ramesa wrote: > Futex waiters are now in a list and some bugs were fixed. > > I think this is now ready for test. I have tested this with > malloc() and free() instead of kalloc() and

[RFC] kern: simple futex for gnumach (version 8)

2013-12-29 Thread Marin Ramesa
dation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Marin Ramesa + */ + +/* + * Fast userspace locking + * + */ + +#include +#include +#include +#include + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +#define futex_list_for_each(array, entry, list) \ +for (entry = &

[RFC] kern: simple futex for gnumach (version 7)

2013-12-28 Thread Marin Ramesa
. + * + * Author: Marin Ramesa + */ + +/* + * Fast userspace locking + * + */ + +#include +#include +#include +#include + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +struct futex_hash_table { + + /* Futex hash table lock. */ + decl_simple_lock_data

Re: [RFC] kern: simple futex for gnumach (version 6)

2013-12-28 Thread Marin Ramesa
On 12/28/2013 11:52:55 AM, Richard Braun wrote: Here is how it probably should be : There should be one futex_waiter struct per thread, allocated on the stack when a thread is about to wait. That structure is then queued on the futex it's waiting for, using the address of the futex as the wakeup

Re: [RFC] kern: simple futex for gnumach (version 6)

2013-12-27 Thread Marin Ramesa
On 12/27/2013 07:14:40 PM, Richard Braun wrote: > +void futex_cross_address_space_wake(futex_t futex, boolean_t wake_all) > +{ > + #define min(x, y) (x <= y ? x : y) > + > + queue_iterate(&futex->chain, futex, futex_t, chain) { > + > + simple_lock(&futex->futex_wait_lock); > + > +

Re: [RFC] kern: simple futex for gnumach (version 6)

2013-12-27 Thread Marin Ramesa
On 12/27/2013 09:58:07 PM, Richard Braun wrote: On Fri, Dec 27, 2013 at 07:55:02PM +0100, Marin Ramesa wrote: > On 12/27/2013 07:14:40 PM, Richard Braun wrote: > >What do you mean when you say you test on the Hurd and Linux ? How do > >you use GDB with Mach to determine it&#x

Re: [RFC] kern: simple futex for gnumach (version 6)

2013-12-27 Thread Marin Ramesa
On 12/27/2013 07:14:40 PM, Richard Braun wrote: On Fri, Dec 27, 2013 at 04:28:33PM +0100, Marin Ramesa wrote: > On Hurd tests fail with a segmentation fault in kalloc() (GDB says kalloc() > segfaults in vm_map_find_entry()). On Linux everything works except segfaults > in vm_m

[RFC] kern: simple futex for gnumach (version 6)

2013-12-27 Thread Marin Ramesa
. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Marin Ramesa + */ + +/* + * Fast userspace locking + * + */ + +#include +#include +#include

Re: [RFC] kern: simple futex for gnumach (version 5)

2013-12-26 Thread Marin Ramesa
On 12/26/2013 03:25:11 PM, Richard Braun wrote: On Thu, Dec 26, 2013 at 03:15:24PM +0100, Marin Ramesa wrote: > I get segfaults in kalloc(). I don't know what I'm doing wrong. Show us how you use it. futex->futexed_threads = (thread_t)kalloc((futex->num_futexed_threa

Re: [RFC] kern: simple futex for gnumach (version 5)

2013-12-26 Thread Marin Ramesa
On 12/26/2013 02:58:01 PM, Richard Braun wrote: Why __builtin_malloc and __builtin_free ?? I get segfaults in kalloc(). I don't know what I'm doing wrong. > + if (futex->num_futexed_threads == 128) > + return FUTEX_RESOURCE_SHORTAGE; I assume this li

[RFC] kern: simple futex for gnumach (version 5)

2013-12-26 Thread Marin Ramesa
Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Marin Ramesa + */ + +/* + * Fast userspace locking + * + */ + +#include +#include + +static futex_hash_table_t table = NULL; +static unsign

Re: [PATCH] kern: simple futex for gnumach (version 4)

2013-12-24 Thread Marin Ramesa
On 12/24/2013 05:20:41 PM, Richard Braun wrote: On Tue, Dec 24, 2013 at 04:55:47PM +0100, Marin Ramesa wrote: > I use a recursive futex_wake(). It first scans all the futexes if > they are on the same offset and if they share the same vm_object. > If they do, recursion is used to wake

Re: [PATCH] kern: simple futex for gnumach (version 4)

2013-12-24 Thread Marin Ramesa
On 12/24/2013 03:25:15 PM, Richard Braun wrote: > There is a one call to vm_map lookup to retrive the offset and the > object. Simple How do you implement cross address space synchronization ? I use a recursive futex_wake(). It first scans all the futexes if they are on the same offset and if

[bug report] segmentation fault in task_create()

2013-12-24 Thread Marin Ramesa
I noticed this while testing the futex call. I don't know how to fix this. The code to reproduce this is the following: extern int task_create(); struct task; typedef struct task *task_t; extern task_t kernel_task; int main(void) { task_t new_task; task_create(kernel_task, 0, &

Re: [PATCH] kern: simple futex for gnumach (version 4)

2013-12-24 Thread Marin Ramesa
On 12/24/2013 11:41:40 AM, Richard Braun wrote: Obviously, you rushed your work without trying to understand what you were doing, and this is becoming frustrating. Don't blindly and mindlessly copy the first thing you see around... 1/ A simpleroutine is a one-way RPC, without a return value othe

Re: [PATCH] kern: simple futex for gnumach (version 3)

2013-12-23 Thread Marin Ramesa
On 23/12/13 10:58:12, Richard Braun wrote: > Now that I think about it, you should already have at least one such > entry on your system, whether Debian or not. Or are you saying you're > not even running the Hurd at all ?! Yes. I'm not running the Hurd. I plan on learning it after I finish with

Re: [PATCH] kern: simple futex for gnumach (version 3)

2013-12-23 Thread Marin Ramesa
On 23/12/13 10:54:47, Richard Braun wrote: > On Sun, Dec 22, 2013 at 11:56:39PM +0100, Marin Ramesa wrote: > > Can you please show me the gnumach menuentry generated by grub? > > How about looking at the documentation ? For example > http://www.gnu.org/software/grub/manual/grub

Re: [PATCH] kern: simple futex for gnumach (version 3)

2013-12-22 Thread Marin Ramesa
On 22/12/13 22:04:15, Richard Braun wrote: > Whether it's in a virtual machine or a real one doesn't matter at > all. On Debian, simply copy the gnumach binary to /boot and run > update-grub. You'll get a new entry at boot time for your kernel. I don't have the update-grub command (I'm not using

Re: [PATCH] kern: simple futex for gnumach (version 3)

2013-12-22 Thread Marin Ramesa
On 22.12.2013 18:25:10, Richard Braun wrote: > On Sun, Dec 22, 2013 at 06:22:03PM +0100, Marin Ramesa wrote: > > On 22.12.2013 17:56:32, Richard Braun wrote: > > > Test it yourself from userspace before you resubmit. > > > > That's the problem. I don't

Re: [PATCH] kern: simple futex for gnumach (version 3)

2013-12-22 Thread Marin Ramesa
On 22.12.2013 17:56:32, Richard Braun wrote: > > OK, I'm reading the documentation. In the meantime I have defined > > several simple RPCs for testing purposes. I will send the updated > > patch shortly. > > Test it yourself from userspace before you resubmit. That's the problem. I don't know ho

[PATCH] kern: simple futex for gnumach (version 4)

2013-12-22 Thread Marin Ramesa
General Public License + * along with this program; if not, write to the Free Software + * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Marin Ramesa + */ + +/* + * Fast userspace locking + * + */ + +#include +#include + +static futex_hash_table_t table = NULL; +static

Re: [PATCH] kern: simple futex for gnumach (version 3)

2013-12-22 Thread Marin Ramesa
On 22.12.2013 01:28:37, Richard Braun wrote: > On Sat, Dec 21, 2013 at 11:29:34PM +0100, Marin Ramesa wrote: > > On 21.12.2013 23:20:43, Richard Braun wrote: > > > How about adding everything necessary to actually test it from > > > userspace ? > > > > Sur

Re: [PATCH] kern: simple futex for gnumach (version 3)

2013-12-21 Thread Marin Ramesa
On 21.12.2013 23:20:43, Richard Braun wrote: > On Sat, Dec 21, 2013 at 10:55:14PM +0100, Marin Ramesa wrote: > > I noticed some bugs. I'm sending a fixed patch. The prevoius > > version is here: > > http://lists.gnu.org/archive/html/bug-hurd/2013-12/msg00493.html >

Re: [RFC] Simple futex for gnumach (version 2)

2013-12-21 Thread Marin Ramesa
On 21.12.2013 23:01:50, Svante Signell wrote: > + * Copyright (c) 2013 Marin Ramesa > + * All rights reserved. > + * > ... > Why not e.g. a GPL licence, even if this function is good it might > not be accepted due to this. I don't know much about licenses, I copied th

[PATCH] kern: simple futex for gnumach (version 3)

2013-12-21 Thread Marin Ramesa
ht (c) 2013 Marin Ramesa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this li

[RFC] Simple futex for gnumach (version 2)

2013-12-21 Thread Marin Ramesa
/kern/futex.c @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2013 Marin Ramesa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must

Re: [PATCH] Avoid the casts in calls to queue function and macros

2013-12-20 Thread Marin Ramesa
On 20.12.2013 19:41:14, Marin Ramesa wrote: > - insque((queue_entry_t) telt, ((queue_entry_t)next)->prev); > + insque(&(telt->chain), *(&(next->chain).prev)); This should be simply: - insque((queue_entry_t) telt, ((queue_entry_t)next)->prev); + i

[PATCH] Avoid the casts in calls to queue function and macros

2013-12-20 Thread Marin Ramesa
Avoid the casts by specifying addresses of queue_chain_t members. If the order of members in the structures ever changes, the code will be correct. --- device/net_io.c | 4 ++-- kern/mach_clock.c | 10 +- kern/processor.c | 2 +- kern/sched_prim.c | 14 +++--- kern/task.c

[PATCH] Mark pure functions with attribute pure

2013-12-20 Thread Marin Ramesa
--- ddb/db_aout.c | 4 ++-- ddb/db_break.c| 4 ++-- ddb/db_break.h| 2 +- ddb/db_command.c | 2 +- ddb/db_command.h | 2 +- ddb/db_output.c | 2 +- ddb/db_output.h | 2 +- ddb/db_run.c | 2 +- ddb/db_sym.c | 2 +- device/dev_name.c | 2 +- include/string.h | 8

[PATCH 1/2] Declare void argument lists (part 2)

2013-12-19 Thread Marin Ramesa
Declare void argument lists that were not declared in the first part of this patch and * kern/sched_prim.h (recompute_priorities): Fix prototype. * kern/startup.c (setup_main) (recompute_priorities): Fix call. --- ddb/db_break.h | 4 ++-- ddb/db_watch.c | 2 +- device/blkio.c |

[PATCH 2/2] ddb/db_watch.c (db_watchpoint_cmd): remove forward declaration

2013-12-19 Thread Marin Ramesa
* ddb/db_watch.c (db_watchpoint_cmd) (db_option): Remove forward declaration. --- ddb/db_watch.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ddb/db_watch.c b/ddb/db_watch.c index 5551e66..dbb4aea 100644 --- a/ddb/db_watch.c +++ b/ddb/db_watch.c @@ -242,7 +242,6 @@ db_watchpoint_cmd(addr, h

[PATCH 2/2] ddb/db_command.c (db_help_cmd): mark with attribute unused

2013-12-19 Thread Marin Ramesa
* ddb/db_command.c (db_help_cmd): Mark with attribute unused. --- ddb/db_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_command.c b/ddb/db_command.c index 3257e07..74134fb 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -382,7 +382,7 @@ struct db_comm

Suggestion to use more of GCC function attributes

2013-12-19 Thread Marin Ramesa
We already have noreturn attribute. I have identified two more attributes that might be useful. These are pure and unused. [PATCH 1/2] kern/strings.c (strlen): mark with attribute pure Attribute pure means that a function doesn't have any effects except the return value, and the return value does

[PATCH 1/2] kern/strings.c (strlen): mark with attribute pure

2013-12-19 Thread Marin Ramesa
* kern/strings.c (strlen): Mark with attribute pure. --- kern/strings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/strings.c b/kern/strings.c index 0752722..72eb4f3 100644 --- a/kern/strings.c +++ b/kern/strings.c @@ -161,7 +161,7 @@ strncpy( * the terminating

Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable

2013-12-18 Thread Marin Ramesa
On 18.12.2013 12:00:49, Richard Braun wrote: > On Wed, Dec 18, 2013 at 11:40:09AM +0100, Marin Ramesa wrote: > > On 18.12.2013 11:34:03, Richard Braun wrote: > > > I don't get this warning, can you tell us how you configure GNU > > > Mach ? > > > > --e

Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable

2013-12-18 Thread Marin Ramesa
On 18.12.2013 11:34:03, Richard Braun wrote: > On Wed, Dec 18, 2013 at 11:25:36AM +0100, Marin Ramesa wrote: > > Yes, vou're right. I got confused. But then something else is > > happening here. When I write the assertion this way: > > > > assert((entry ==

Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable

2013-12-18 Thread Marin Ramesa
On 18.12.2013 11:11:10, Richard Braun wrote: > The expression is ((a == NULL) || a->something), and I agree it is > equivalent to !((a != NULL) && !a->something). And again, both the > && and || operators are guaranteed to be evaluated left-to-right and > *yield* without evaluating the second opera

Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable

2013-12-18 Thread Marin Ramesa
On 18.12.2013 10:55:47, Marin Ramesa wrote: > in order to return TRUE Sorry, I meant to say in order to return FALSE.

Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable

2013-12-18 Thread Marin Ramesa
On 18.12.2013 10:46:40, Richard Braun wrote: > On Wed, Dec 18, 2013 at 10:37:03AM +0100, Marin Ramesa wrote: > > Compiler needs to check both !a and !b. In order to evaluate !b it > > must evaluate b. So when the code path is that when entry is a null > > pointer, the evaluat

Re: [PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable

2013-12-18 Thread Marin Ramesa
On 18.12.2013 10:20:21, Anatoly A. Kazantsev wrote: > On Wed, 18 Dec 2013 09:17:47 +0100 > Marin Ramesa wrote: > > > ... > > Negation of an > > OR expression is an AND expression. > > ... > > Maybe I did't get you correctly, but isn't !(a |

[PATCH 1/3] ipc: avoid dereference of null pointer and quiet the GCC warning about uninitialized variable

2013-12-18 Thread Marin Ramesa
The problem is in this statement: assert((entry == IE_NULL) || IE_BITS_TYPE(entry->ie_bits)); The macro assert() checks for a negation of this expression. Negation of an OR expression is an AND expression. In order to evaluate an AND expression, compiler needs to check both conditions. So it firs

[PATCH 2/3] ipc/mach_debug.c (host_ipc_hash_info): quiet GCC warning about uninitialized variable

2013-12-18 Thread Marin Ramesa
Don't initialize to zero, rather move the initialization of size before the break statement. Break on the first iteration should never happen, so the position of initialization doesn't matter. * ipc/mach_debug.c (host_ipc_hash_info) (size): Don't initialize to zero. (host_ipc_hash_info) (size): Mo

[PATCH 3/3] vm/vm_debug.c: quiet GCC warning about uninitialized variable

2013-12-18 Thread Marin Ramesa
The same situation as the previous patch. * vm/vm_debug.c (host_virtual_physical_table_info) (size): Don't initialize to zero. (host_virtual_physical_table_info) (size): Move initialization before the break statement. --- vm/vm_debug.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-

Re: [PATCH 3/4] device/chario.c: qualify pointers that access their dereferenced values under locks with __restrict__

2013-12-17 Thread Marin Ramesa
On 18.12.2013 00:17:38, Richard Braun wrote: > On Tue, Dec 17, 2013 at 03:58:27PM +0100, Marin Ramesa wrote: > > Qualifier __restrict__ means that only the pointer under > > __restrict__ will be used to access dereferenced values. So if a > > code is under locks and no func

[PATCH 3/4] device/chario.c: qualify pointers that access their dereferenced values under locks with __restrict__

2013-12-17 Thread Marin Ramesa
Qualifier __restrict__ means that only the pointer under __restrict__ will be used to access dereferenced values. So if a code is under locks and no function is called in the critical section with pointer as an argument, it's safe to use __restrict__. This allows the compiler to make optimizatio

[PATCH 2/4] Cleanup of the copyin() and copyout() calls

2013-12-17 Thread Marin Ramesa
* device/ds_routines.c (device_write_trap) (copyin) (data): Cast to (void *). Argument is an address. (device_write_trap) (copyin) (io_data): Don't cast. (device_writev_trap) (copyin) (iovec, stack_iovec): Likewise. (device_writev_trap) (copyin) (data, p): Cast to (void *). Arguments are addresse

[PATCH 4/4] device/device_emul.h (device_emulation_ops): modify so that correct argument types are listed

2013-12-17 Thread Marin Ramesa
Modify structure device_emulation_ops so that correct argument types are listed. This patch produces warnings in the linux code. There is a previous version of this patch here: http://lists.gnu.org/archive/html/bug-hurd/2013-11/msg00482.html * device/device_emul.h (device_emulation_ops): Modify.

[PATCH 1/4] kern/sched_prim.h: remove unnecessary __GNUC__ #ifdef

2013-12-17 Thread Marin Ramesa
Attribute noreturn is used irrespective of __GNUC__. Remove unnecessary #ifdef. * kern/sched_prim.h [__GNUC__]: Remove #ifdef. --- kern/sched_prim.h | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kern/sched_prim.h b/kern/sched_prim.h index 07b5bf0..c7ff977 100644 --- a/k

[PATCH 6/8] vm: qualify pointers whose dereferenced values are constant with const

2013-12-16 Thread Marin Ramesa
--- vm/memory_object.c | 4 ++-- vm/memory_object_proxy.c | 8 vm/memory_object_proxy.h | 8 vm/vm_debug.c| 2 +- vm/vm_external.c | 4 ++-- vm/vm_map.c | 8 vm/vm_print.h| 4 ++-- vm/vm_resident.c | 2 +- vm/vm_

[PATCH 5/8] util: qualify pointers whose dereferenced values are constant with const

2013-12-16 Thread Marin Ramesa
--- util/atoi.c | 8 util/atoi.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/util/atoi.c b/util/atoi.c index 64816b9..e56f50d 100644 --- a/util/atoi.c +++ b/util/atoi.c @@ -91,11 +91,11 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ int mach_atoi(cp, nu

[PATCH 8/8] kern: avoid the casts in enqueue_head() and enqueue_tail()

2013-12-16 Thread Marin Ramesa
* kern/eventcount.c (simpler_thread_setrun) (enqueue_head) (th): Avoid the cast. * kern/thread.c (thread_halt_self) (enqueue_tail) (thread): Likewise. * kern/thread_swap.c (thread_swapin) (enqueue_tail) (thread): Likewise. --- kern/eventcount.c | 2 +- kern/thread.c | 2 +- kern/thread_swap

[PATCH 4/8] kern: qualify pointers whose dereferenced values are constant with const

2013-12-16 Thread Marin Ramesa
--- kern/assert.h| 2 +- kern/boot_script.c | 4 ++-- kern/debug.c | 6 +++--- kern/debug.h | 4 ++-- kern/eventcount.c| 2 +- kern/host.c | 12 ++-- kern/ipc_host.c | 2 +- kern/ipc_mig.c | 5 +++-- k

[PATCH 7/8] Mark functions that don't return with attribute noreturn

2013-12-16 Thread Marin Ramesa
--- device/ds_routines.c | 2 +- device/ds_routines.h | 2 +- device/net_io.c | 2 +- device/net_io.h | 2 +- kern/eventcount.c| 2 +- kern/machine.c | 2 +- kern/machine.h | 2 +- kern/sched_prim.c| 2 +- kern/sched_prim.h| 8 kern/thread.c| 4 ++

[PATCH 2/8] i386: qualify pointers whose dereferenced values are constant with const

2013-12-16 Thread Marin Ramesa
--- i386/i386/ast_check.c| 4 ++-- i386/i386/db_disasm.c| 10 +- i386/i386/db_interface.c | 14 +++--- i386/i386/db_interface.h | 2 +- i386/i386/db_trace.c | 14 +++--- i386/i386/debug.h| 2 +- i386/i386/debug_i386.c | 2 +- i386/i386/fpu.c

[PATCH 1/8] device: qualify pointers whose dereferenced values are constant with const

2013-12-16 Thread Marin Ramesa
--- device/chario.c | 10 +++ device/dev_hdr.h | 10 +++ device/dev_lookup.c | 10 +++ device/dev_name.c| 14 +- device/dev_pager.c | 74 ++-- device/ds_routines.c | 28 ++-- device/ds_routines.h |

[PATCH 3/8] ipc: qualify pointers whose dereferenced values are constant with const

2013-12-16 Thread Marin Ramesa
--- ipc/ipc_entry.c | 2 +- ipc/ipc_mqueue.c | 6 +++--- ipc/ipc_object.c | 2 +- ipc/ipc_port.c | 8 ipc/ipc_print.h | 6 +++--- ipc/ipc_pset.c | 2 +- ipc/mach_rpc.c | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ipc/ipc_entry.c b/ipc/ipc_entry.c index

[PATCH 2/2] kern: quiet GCC warnings about set but unused variables

2013-12-15 Thread Marin Ramesa
* kern/lock.h (simple_lock_data_empty): Define. (decl_simple_lock_data, simple_unlock): Likewise. * kern/sched_prim.c (lock): Declare. [MACH_SLOCKS]: Remove #ifs. * kern/task.c (task_lock, task_unlock): Remove address operator. --- kern/lock.h | 6 -- kern/sched_prim.c | 18 +++

[PATCH 1/2] Quiet GCC warning about uninitialized variable

2013-12-15 Thread Marin Ramesa
* ddb/db_command.h (db_error): Mark with attribute noreturn. * i386/i386/setjmp.h (_longjmp): Likewise. --- ddb/db_command.h | 2 +- i386/i386/setjmp.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ddb/db_command.h b/ddb/db_command.h index 5f0236a..634dd9d 100644 --- a/

Re: [PATCH 3/6] ddb/db_break.c (db_delete_cmd): add missing returns

2013-12-15 Thread Marin Ramesa
On 15.12.2013 20:25:24, Samuel Thibault wrote: > Marin Ramesa, le Sun 15 Dec 2013 20:22:02 +0100, a écrit : > > On 15.12.2013 20:14:03, Samuel Thibault wrote: > > > Marin Ramesa, le Thu 12 Dec 2013 18:27:05 +0100, a écrit : > > > > There is a code p

[PATCH 1/2] i386/i386/db_trace.c: use (long *) instead of an (int *)

2013-12-15 Thread Marin Ramesa
* i386/i386/db_trace.c (db_lookup_i386_kreg) (kregp): Use (long *) instead of an (int *). --- i386/i386/db_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index 6247d4f..d0c434e 100644 --- a/i386/i386/db_trace.c +++ b/i386/i

[PATCH 2/2] kern/lock.h: quiet GCC warnings about set but unused variables

2013-12-15 Thread Marin Ramesa
* kern/lock.h (simple_lock_data_empty): Define. (decl_simple_lock_data, simple_unlock): Likewise. * kern/sched_prim.c (lock): Declare. * kern/task.c (task_lock, task_unlock) (task): Remove address operator. --- kern/lock.h | 6 -- kern/sched_prim.c | 6 ++ kern/task.c | 4 ++--

Re: [PATCH 2/6] kern/lock.h: quiet GCC warnings about set but unused variables

2013-12-15 Thread Marin Ramesa
On 15.12.2013 20:13:22, Samuel Thibault wrote: > > index 8fe3672..67067cf 100644 > > --- a/kern/task.c > > +++ b/kern/task.c > > @@ -769,7 +769,7 @@ kern_return_t task_info( > > event_info->cow_faults = task->cow_faults; > > event_info->messages_sent = task->messages_sent;

Re: [PATCH 3/6] ddb/db_break.c (db_delete_cmd): add missing returns

2013-12-15 Thread Marin Ramesa
On 15.12.2013 20:14:03, Samuel Thibault wrote: > Marin Ramesa, le Thu 12 Dec 2013 18:27:05 +0100, a écrit : > > There is a code path when db_error() can return. > > Which one? When _longjmp() returns and db_recover and argument to db_error() are non-zero.

Re: [PATCH 4/4] device/chario.c (char_write): avoid segmentation fault

2013-12-15 Thread Marin Ramesa
On 15.12.2013 14:00:22, Richard Braun wrote: > On Sat, Dec 14, 2013 at 01:32:27PM +0100, Marin Ramesa wrote: > > On 14.12.2013 12:45:32, Richard Braun wrote: > > > I really don't see a problem in that code, you'll have to > > > describe it better. > >

[PATCH] ddb: qualify pointers whose dereferenced values are constant with const

2013-12-15 Thread Marin Ramesa
--- chips/busses.c | 8 chips/busses.h | 8 ddb/db_aout.c| 34 +- ddb/db_break.c | 20 ++-- ddb/db_break.h | 12 ++-- ddb/db_command.c | 22 +++--- ddb/db_command.h |

[PATCH] device/chario.c (char_write): avoid segmentation fault

2013-12-14 Thread Marin Ramesa
This is a better version of this patch: http://lists.gnu.org/archive/html/bug-hurd/2013-12/msg00400.html It uses strlen(), instead of reimplementing it. * device/chario.c: Include string.h. (char_write): New if statement. --- device/chario.c | 5 + 1 file changed, 5 insertions(+) diff --g

Re: [PATCH 4/4] device/chario.c (char_write): avoid segmentation fault

2013-12-14 Thread Marin Ramesa
On 14.12.2013 12:45:32, Richard Braun wrote: > On Fri, Dec 13, 2013 at 09:06:55PM +0100, Marin Ramesa wrote: > > Check if the source of the data in the source structure > > memory is a target structure data. Do this by comparing the > > length of the char values starting wi

[PATCH] Type definition

2013-12-14 Thread Marin Ramesa
This is a better version of this patch: http://lists.gnu.org/archive/html/bug-hurd/2013-11/msg00474.html * i386/i386/ast_check.c (init_ast_check, cause_ast_check): Define return type. * i386/i386/pic.c (intnull, prtnull): Define argument types. * i386/i386at/com.c (compr_addr): Likewise. (compr):

[PATCH 3/4] device/dev_pager.c (device_pager_data_request_done): cast to size_t instead to unsigned

2013-12-13 Thread Marin Ramesa
* device/dev_pager.c (device_pager_data_request_done) (memset) (io_residual): Cast to size_t instead to unsigned. --- device/dev_pager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/dev_pager.c b/device/dev_pager.c index b9796ca..7c3e088 100644 --- a/device/dev_page

[PATCH 4/4] device/chario.c (char_write): avoid segmentation fault

2013-12-13 Thread Marin Ramesa
The situation is that there is a pointer (source) that is being cast to another pointer (target) and then the members of the target structure pointed to by the target pointer are being used as if the content of memory at the source address is a target structure, not source structure pointed to by

[PATCH 2/4] device/dev_pager.c: remove unnecessary casts

2013-12-13 Thread Marin Ramesa
Variable pager is already of ipc_port_t type. * device/dev_pager.c: Remove unnecessary casts. --- device/dev_pager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/dev_pager.c b/device/dev_pager.c index 97e417e..b9796ca 100644 --- a/device/dev_pager.c +++ b/device

[PATCH 1/4] kern/sched_prim.c: avoid casts

2013-12-13 Thread Marin Ramesa
Avoid the casts by passing the address of the links thread structure member to enqueue_tail(). * kern/sched_prim.c: Avoid casts. --- kern/sched_prim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kern/sched_prim.c b/kern/sched_prim.c index c06cd77..ec041fc 100644 ---

[PATCH 5/6] ddb/db_expr.c (db_mult_expr): initialize lhs

2013-12-12 Thread Marin Ramesa
Initialize lhs to zero to avoid uninitialized usage in db_unary(). * ddb/db_expr.c (db_mult_expr) (lhs): Initialize to zero. --- ddb/db_expr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_expr.c b/ddb/db_expr.c index eee9e4f..82ada58 100644 --- a/ddb/db_expr.c +++ b

[PATCH 6/6] i386/i386/db_trace.c (db_i386_reg_value): cast to (int *) instead to (long *)

2013-12-12 Thread Marin Ramesa
This quiets the GCC warning about passing from incompatible pointer type. * i386/i386/db_trace.c (db_i386_reg_value) (db_lookup_i386_kreg) (STACK_IKS): Cast to (int *) instead to (long *). --- i386/i386/db_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/db_

[PATCH 3/6] ddb/db_break.c (db_delete_cmd): add missing returns

2013-12-12 Thread Marin Ramesa
There is a code path when db_error() can return. Avoid, by writing returns, deleting the breakpoint when breakpoint number is not valid or there is no such breakpoint. * ddb/db_break.c (db_delete_cmd): Add missing returns. --- ddb/db_break.c | 2 ++ 1 file changed, 2 insertions(+) diff --git

[PATCH 4/6] ddb/db_break.c (db_delete_cmd): remove unnecessary initialization

2013-12-12 Thread Marin Ramesa
Now that we have returns there are no more warnings from GCC about uninitialized variable. Remove unnecessary initialization of variable bkpt. * ddb/db_break.c (db_delete_cmd) (bkpt): Remove unnecessary initialization. --- ddb/db_break.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) di

[PATCH 1/6] ddb/db_break.c (db_find_breakpoint_here): remove unnecessary casts

2013-12-12 Thread Marin Ramesa
Variable addr and member address are already of db_addr_t type which is type defined as vm_offset_t. * ddb/db_break.c (db_find_breakpoint_here) (DB_PHYS_EQ) (addr, address): Remove unecessary casts. --- ddb/db_break.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_br

[PATCH 2/6] kern/lock.h: quiet GCC warnings about set but unused variables

2013-12-12 Thread Marin Ramesa
This is a better version of these two patches: http://lists.gnu.org/archive/html/bug-hurd/2013-12/msg6.html http://lists.gnu.org/archive/html/bug-hurd/2013-12/msg00375.html It uses an empty structure to represent a lock when !MACH_SLOCKS and a modified simple_unlock() to quiet GCC warnings ab

Re: [PATCH 4/8] Quiet GCC warnings about set but unused variables

2013-12-12 Thread Marin Ramesa
On 12.12.2013 01:31:06, Richard Braun wrote: > On Wed, Dec 11, 2013 at 09:07:38PM +0100, Marin Ramesa wrote: > > On 11.12.2013 18:02:50, Richard Braun wrote: > > > On Wed, Dec 11, 2013 at 05:30:43PM +0100, Marin Ramesa wrote: > > > > - ipc_mqueue_t mqueue; >

Re: [PATCH 7/8] vm/vm_resident.c (vm_page_print): remove unnecessary casts

2013-12-11 Thread Marin Ramesa
On 11.12.2013 19:12:33, Ivan Shmakov wrote: > > Even though I’m unsure how vm_offset_t is defined (is it int? > or is it ptrdiff_t? ¹), I’d rather like to see casts to /int/ > here, as it’s what %X (usually – no idea about vm/*) implies. > > ¹ Please note that while int is 32 bits on

Re: [PATCH 4/8] Quiet GCC warnings about set but unused variables

2013-12-11 Thread Marin Ramesa
On 11.12.2013 18:02:50, Richard Braun wrote: > On Wed, Dec 11, 2013 at 05:30:43PM +0100, Marin Ramesa wrote: > > - ipc_mqueue_t mqueue; > > + ipc_mqueue_t mqueue = mqueue; /* Quiet GCC warning. */ > > Don't do that. Instead, tweak simple_unlock and similar functions

[PATCH 8/8] mig/server.c (WriteVarDecls): quiet GCC warning about set but unused variable

2013-12-11 Thread Marin Ramesa
This is again that code where variable is assigned to itself, but I don't know how to fix this the other way. * server.c (WriteVarDecls) (msgh_simple): Assign to itself. --- server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.c b/server.c index 8496da7..793b9f

[PATCH 7/8] vm/vm_resident.c (vm_page_print): remove unnecessary casts

2013-12-11 Thread Marin Ramesa
Members offset and phys_addr are of vm_offset_t types. * vm/vm_resident.c (vm_page_print) (offset, phys_addr): Remove unnecessary casts. --- vm/vm_resident.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/vm_resident.c b/vm/vm_resident.c index f0f31f6..dc99a79 100644

[PATCH 6/8] vm/vm_kern.c (kmem_submap): remove unnecessary cast

2013-12-11 Thread Marin Ramesa
The return value from vm_map_min() is already of vm_offset_t type. * vm/vm_kern.c (kmem_submap) (addr): Remove unnecessary cast. --- vm/vm_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_kern.c b/vm/vm_kern.c index 7e377ef..1c843ff 100644 --- a/vm/vm_kern.c +++ b

  1   2   3   4   5   6   >