@@ -281,6 +281,7 @@
endif
runtime_files = \
+ runtime/go-assert.c \
runtime/go-assert-interface.c \
runtime/go-bad-index.c \
runtime/go-byte-array-to-string.c \
@@ -4,9 +4,8 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
-
#include "go-alloc.h"
+#include "go-assert.h"
#include "go-panic.h"
#include "interface.h"
@@ -41,7 +40,7 @@
/* A type assertion to an empty interface just returns the object
descriptor. */
- assert (lhs_descriptor->__code == GO_INTERFACE);
+ __go_assert (lhs_descriptor->__code == GO_INTERFACE);
lhs_interface = (const struct __go_interface_type *) lhs_descriptor;
if (lhs_interface->__methods.__count == 0)
return rhs_descriptor;
@@ -0,0 +1,18 @@
+/* go-assert.c -- libgo specific assertions
+
+ Copyright 2010 The Go Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style
+ license that can be found in the LICENSE file. */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "go-assert.h"
+
+void
+__go_assert_fail (const char *file, unsigned int lineno)
+{
+ /* FIXME: Eventually we should dump a stack trace here. */
+ fprintf (stderr, "%s:%u: libgo assertion failure\n", file, lineno);
+ abort ();
+}
@@ -0,0 +1,18 @@
+/* go-assert.h -- libgo specific assertions
+
+ Copyright 2010 The Go Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style
+ license that can be found in the LICENSE file. */
+
+#ifndef LIBGO_GO_ASSERT_H
+#define LIBGO_GO_ASSERT_H
+
+/* We use a Go specific assert function so that functions which call
+ assert aren't required to always split the stack. */
+
+extern void __go_assert_fail (const char *file, unsigned int lineno)
+ __attribute__ ((noreturn));
+
+#define __go_assert(e) ((e) ? (void) 0 : __go_assert_fail (__FILE__, __LINE__))
+
+#endif /* !defined(LIBGO_GO_ASSERT_H) */
@@ -4,8 +4,7 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
-
+#include "go-assert.h"
#include "go-type.h"
#include "interface.h"
@@ -30,7 +29,7 @@
if (from_descriptor == NULL)
return 0;
- assert (to_descriptor->__code == GO_INTERFACE);
+ __go_assert (to_descriptor->__code == GO_INTERFACE);
to_interface = (const struct __go_interface_type *) to_descriptor;
to_method_count = to_interface->__methods.__count;
to_method = ((const struct __go_interface_method *)
@@ -4,9 +4,9 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
#include <stddef.h>
+#include "go-assert.h"
#include "channel.h"
/* Return the cap function applied to a channel--the size of the
@@ -23,7 +23,7 @@
return 0;
i = pthread_mutex_lock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
if (channel->num_entries == 0)
ret = 0;
@@ -35,7 +35,7 @@
}
i = pthread_mutex_unlock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
return ret;
}
@@ -4,9 +4,9 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
#include <stddef.h>
+#include "go-assert.h"
#include "channel.h"
/* Return the len function applied to a channel--the number of
@@ -24,7 +24,7 @@
return 0;
i = pthread_mutex_lock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
if (channel->num_entries == 0)
ret = 0;
@@ -35,7 +35,7 @@
% channel->num_entries);
i = pthread_mutex_unlock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
return ret;
}
@@ -4,8 +4,6 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
-
#include "go-panic.h"
#include "interface.h"
@@ -4,8 +4,7 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
-
+#include "go-assert.h"
#include "channel.h"
/* Close a channel. After a channel is closed, sends are no longer
@@ -17,18 +16,18 @@
int i;
i = pthread_mutex_lock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
while (channel->selected_for_send)
{
i = pthread_cond_wait (&channel->cond, &channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
channel->is_closed = 1;
i = pthread_cond_broadcast (&channel->cond);
- assert (i == 0);
+ __go_assert (i == 0);
__go_unlock_and_notify_selects (channel);
}
@@ -4,8 +4,7 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
-
+#include "go-assert.h"
#include "channel.h"
/* Return whether a channel is closed. We only return true after at
@@ -18,18 +17,18 @@
_Bool ret;
i = pthread_mutex_lock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
while (channel->selected_for_receive)
{
i = pthread_cond_wait (&channel->cond, &channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
ret = channel->saw_close;
i = pthread_mutex_unlock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
return ret;
}
@@ -4,7 +4,6 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
@@ -4,9 +4,8 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
-
#include "go-alloc.h"
+#include "go-assert.h"
#include "go-panic.h"
#include "interface.h"
@@ -39,14 +38,14 @@
return NULL;
}
- assert (lhs_descriptor->__code == GO_INTERFACE);
+ __go_assert (lhs_descriptor->__code == GO_INTERFACE);
lhs_interface = (const struct __go_interface_type *) lhs_descriptor;
lhs_method_count = lhs_interface->__methods.__count;
lhs_methods = ((const struct __go_interface_method *)
lhs_interface->__methods.__values);
/* This should not be called for an empty interface. */
- assert (lhs_method_count > 0);
+ __go_assert (lhs_method_count > 0);
rhs_uncommon = rhs_descriptor->__uncommon;
if (rhs_uncommon == NULL || rhs_uncommon->__methods.__count == 0)
@@ -4,7 +4,6 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <signal.h>
@@ -14,6 +13,7 @@
#include <semaphore.h>
#include "config.h"
+#include "go-assert.h"
#include "go-panic.h"
#include "go-alloc.h"
#include "runtime.h"
@@ -98,7 +98,7 @@
mcache = m->mcache;
i = pthread_mutex_lock (&__go_thread_ids_lock);
- assert (i == 0);
+ __go_assert (i == 0);
if (list_entry->prev != NULL)
list_entry->prev->next = list_entry->next;
@@ -113,7 +113,7 @@
FixAlloc_Free (&mheap.cachealloc, mcache);
i = pthread_mutex_unlock (&__go_thread_ids_lock);
- assert (i == 0);
+ __go_assert (i == 0);
free (list_entry);
}
@@ -151,7 +151,7 @@
/* Finish up the entry on the thread list. */
i = pthread_mutex_lock (&__go_thread_ids_lock);
- assert (i == 0);
+ __go_assert (i == 0);
list_entry->id = pthread_self ();
list_entry->pfn = NULL;
@@ -159,7 +159,7 @@
list_entry->tentative = 0;
i = pthread_mutex_unlock (&__go_thread_ids_lock);
- assert (i == 0);
+ __go_assert (i == 0);
(*pfn) (arg);
@@ -192,9 +192,9 @@
pthread_t tid;
i = pthread_attr_init (&attr);
- assert (i == 0);
+ __go_assert (i == 0);
i = pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
- assert (i == 0);
+ __go_assert (i == 0);
#ifdef LINKER_SUPPORTS_SPLIT_STACK
/* The linker knows how to handle calls between code which uses
@@ -206,7 +206,7 @@
#define PTHREAD_STACK_MIN 8192
#endif
i = pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
- assert (i == 0);
+ __go_assert (i == 0);
#endif
newm = __go_alloc (sizeof (M));
@@ -224,7 +224,7 @@
/* Add the thread to the list of all threads, marked as tentative
since it is not yet ready to go. */
i = pthread_mutex_lock (&__go_thread_ids_lock);
- assert (i == 0);
+ __go_assert (i == 0);
/* We use __go_thread_ids_lock as a lock for mheap.cachealloc. */
newm->mcache = allocmcache ();
@@ -235,14 +235,14 @@
__go_all_thread_ids = list_entry;
i = pthread_mutex_unlock (&__go_thread_ids_lock);
- assert (i == 0);
+ __go_assert (i == 0);
/* Start the thread. */
i = pthread_create (&tid, &attr, start_go_thread, newm);
- assert (i == 0);
+ __go_assert (i == 0);
i = pthread_attr_destroy (&attr);
- assert (i == 0);
+ __go_assert (i == 0);
}
/* This is the signal handler for GO_SIG_START. The garbage collector
@@ -294,7 +294,7 @@
/* Tell the garbage collector that we are ready by posting to the
semaphore. */
i = sem_post (&__go_thread_ready_sem);
- assert (i == 0);
+ __go_assert (i == 0);
/* Wait for the garbage collector to tell us to continue. */
sigsuspend (&__go_thread_wait_sigset);
@@ -361,7 +361,7 @@
struct __go_thread_id *p;
i = pthread_mutex_lock (&__go_thread_ids_lock);
- assert (i == 0);
+ __go_assert (i == 0);
me = pthread_self ();
c = 0;
@@ -409,7 +409,7 @@
i = sem_wait (&__go_thread_ready_sem);
if (i < 0 && errno == EINTR)
continue;
- assert (i == 0);
+ __go_assert (i == 0);
--c;
}
@@ -546,7 +546,7 @@
}
i = pthread_mutex_unlock (&__go_thread_ids_lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
/* Initialize the interaction between goroutines and the garbage
@@ -576,50 +576,50 @@
GC. */
i = sem_init (&__go_thread_ready_sem, 0, 0);
- assert (i == 0);
+ __go_assert (i == 0);
/* Fetch the current signal mask. */
i = sigemptyset (&sset);
- assert (i == 0);
+ __go_assert (i == 0);
i = sigprocmask (SIG_BLOCK, NULL, &sset);
- assert (i == 0);
+ __go_assert (i == 0);
/* Make sure that GO_SIG_START is not blocked and GO_SIG_STOP is
blocked, and save that set for use with later calls to sigsuspend
while waiting for GC to complete. */
i = sigdelset (&sset, GO_SIG_START);
- assert (i == 0);
+ __go_assert (i == 0);
i = sigaddset (&sset, GO_SIG_STOP);
- assert (i == 0);
+ __go_assert (i == 0);
__go_thread_wait_sigset = sset;
/* Block SIG_SET_START and unblock SIG_SET_STOP, and use that for
the process signal mask. */
i = sigaddset (&sset, GO_SIG_START);
- assert (i == 0);
+ __go_assert (i == 0);
i = sigdelset (&sset, GO_SIG_STOP);
- assert (i == 0);
+ __go_assert (i == 0);
i = sigprocmask (SIG_SETMASK, &sset, NULL);
- assert (i == 0);
+ __go_assert (i == 0);
/* Install the signal handlers. */
memset (&act, 0, sizeof act);
i = sigemptyset (&act.sa_mask);
- assert (i == 0);
+ __go_assert (i == 0);
act.sa_handler = gc_start_handler;
act.sa_flags = SA_RESTART;
i = sigaction (GO_SIG_START, &act, NULL);
- assert (i == 0);
+ __go_assert (i == 0);
/* We could consider using an alternate signal stack for this. The
function does not use much stack space, so it may be OK. */
act.sa_handler = gc_stop_handler;
i = sigaction (GO_SIG_STOP, &act, NULL);
- assert (i == 0);
+ __go_assert (i == 0);
#ifndef USING_SPLIT_STACK
/* If we don't support split stack, record the current stack as the
@@ -4,8 +4,7 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
-
+#include "go-assert.h"
#include "go-string.h"
#include "runtime.h"
#include "malloc.h"
@@ -80,7 +79,7 @@
}
}
- assert ((size_t) (s - retdata) == slen);
+ __go_assert ((size_t) (s - retdata) == slen);
return ret;
}
@@ -4,11 +4,11 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include "go-alloc.h"
+#include "go-assert.h"
#include "map.h"
/* Delete the entry matching KEY from MAP. */
@@ -30,7 +30,7 @@
key_descriptor = descriptor->__map_descriptor->__key_type;
key_offset = descriptor->__key_offset;
key_size = key_descriptor->__size;
- assert (key_size != 0 && key_size != -1UL);
+ __go_assert (key_size != 0 && key_size != -1UL);
equalfn = key_descriptor->__equalfn;
key_hash = key_descriptor->__hashfn (key, key_size);
@@ -4,11 +4,11 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include "go-alloc.h"
+#include "go-assert.h"
#include "map.h"
/* Rehash MAP to a larger size. */
@@ -90,7 +90,7 @@
key_descriptor = descriptor->__map_descriptor->__key_type;
key_offset = descriptor->__key_offset;
key_size = key_descriptor->__size;
- assert (key_size != 0 && key_size != -1UL);
+ __go_assert (key_size != 0 && key_size != -1UL);
equalfn = key_descriptor->__equalfn;
key_hash = key_descriptor->__hashfn (key, key_size);
@@ -4,8 +4,7 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
-
+#include "go-assert.h"
#include "map.h"
/* Initialize a range over a map. */
@@ -72,7 +71,7 @@
descriptor = map->__descriptor;
key_descriptor = descriptor->__map_descriptor->__key_type;
p = it->entry;
- assert(p != NULL);
+ __go_assert (p != NULL);
__builtin_memcpy (key, p + descriptor->__key_offset, key_descriptor->__size);
}
@@ -95,7 +94,7 @@
key_descriptor = map_descriptor->__key_type;
val_descriptor = map_descriptor->__val_type;
p = it->entry;
- assert(p != NULL);
+ __go_assert (p != NULL);
__builtin_memcpy (key, p + descriptor->__key_offset,
key_descriptor->__size);
__builtin_memcpy (val, p + descriptor->__val_offset,
@@ -4,9 +4,9 @@
// Return time in nanoseconds. This is only used for computing runtime.
-#include <assert.h>
#include <sys/time.h>
+#include "go-assert.h"
#include "runtime.h"
int64
@@ -16,7 +16,7 @@
struct timeval tv;
i = gettimeofday (&tv, NULL);
- assert (i == 0);
+ __go_assert (i == 0);
return (int64) tv.tv_sec * 1000000000 + (int64) tv.tv_usec * 1000;
}
@@ -5,11 +5,10 @@
license that can be found in the LICENSE file. */
#include <stddef.h>
-#include <assert.h>
-
-#include "channel.h"
#include "go-alloc.h"
+#include "go-assert.h"
+#include "channel.h"
struct __go_channel*
__go_new_channel (size_t element_size, size_t entries)
@@ -32,9 +31,9 @@
* alloc_size
* sizeof (uint64_t)));
i = pthread_mutex_init (&ret->lock, NULL);
- assert (i == 0);
+ __go_assert (i == 0);
i = pthread_cond_init (&ret->cond, NULL);
- assert (i == 0);
+ __go_assert (i == 0);
ret->element_size = element_size;
ret->closed_op_count = 0;
ret->waiting_to_send = 0;
@@ -8,8 +8,7 @@
notesleep waits for a call to notewakeup. notewakeup wakes up
every thread waiting on the note. */
-#include <assert.h>
-
+#include "go-assert.h"
#include "runtime.h"
/* We use a single global lock and condition variable. It would be
@@ -27,12 +26,12 @@
int32 i;
i = pthread_mutex_lock (¬e_lock);
- assert (i == 0);
+ __go_assert (i == 0);
n->woken = 0;
i = pthread_mutex_unlock (¬e_lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
/* Wait until notewakeup is called. */
@@ -43,16 +42,16 @@
int32 i;
i = pthread_mutex_lock (¬e_lock);
- assert (i == 0);
+ __go_assert (i == 0);
while (!n->woken)
{
i = pthread_cond_wait (¬e_cond, ¬e_lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
i = pthread_mutex_unlock (¬e_lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
/* Wake up every thread sleeping on the note. */
@@ -63,13 +62,13 @@
int32 i;
i = pthread_mutex_lock (¬e_lock);
- assert (i == 0);
+ __go_assert (i == 0);
n->woken = 1;
i = pthread_cond_broadcast (¬e_cond);
- assert (i == 0);
+ __go_assert (i == 0);
i = pthread_mutex_unlock (¬e_lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
@@ -5,7 +5,6 @@
license that can be found in the LICENSE file. */
#include <stdint.h>
-#include <assert.h>
#include "channel.h"
@@ -5,7 +5,6 @@
license that can be found in the LICENSE file. */
#include <stdint.h>
-#include <assert.h>
#include "channel.h"
@@ -5,8 +5,8 @@
license that can be found in the LICENSE file. */
#include <stdint.h>
-#include <assert.h>
+#include "go-assert.h"
#include "go-panic.h"
#include "channel.h"
@@ -19,12 +19,12 @@
_Bool has_data;
i = pthread_mutex_lock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
while (channel->selected_for_receive)
{
i = pthread_cond_wait (&channel->cond, &channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
if (channel->is_closed
@@ -38,7 +38,7 @@
if (channel->closed_op_count >= MAX_CLOSED_OPERATIONS)
{
i = pthread_mutex_unlock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
__go_panic_msg ("too many operations on closed channel");
}
}
@@ -72,7 +72,7 @@
while (channel->next_store == 0)
{
i = pthread_cond_wait (&channel->cond, &channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
has_data = 1;
@@ -86,14 +86,14 @@
if (has_data)
{
channel->waiting_to_receive = 1;
- assert (channel->next_store == 1);
+ __go_assert (channel->next_store == 1);
}
}
if (!has_data)
{
i = pthread_mutex_unlock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
return RECEIVE_NONBLOCKING_ACQUIRE_NODATA;
}
@@ -107,7 +107,7 @@
{
struct __go_receive_nonblocking_small ret;
- assert (channel->element_size <= sizeof (uint64_t));
+ __go_assert (channel->element_size <= sizeof (uint64_t));
int data = __go_receive_nonblocking_acquire (channel);
if (data != RECEIVE_NONBLOCKING_ACQUIRE_DATA)
@@ -5,8 +5,8 @@
license that can be found in the LICENSE file. */
#include <stdint.h>
-#include <assert.h>
+#include "go-assert.h"
#include "go-panic.h"
#include "channel.h"
@@ -26,10 +26,10 @@
struct __go_channel_select *p;
int i;
- assert (channel->num_entries == 0);
+ __go_assert (channel->num_entries == 0);
i = pthread_mutex_lock (&__go_select_data_mutex);
- assert (i == 0);
+ __go_assert (i == 0);
for (p = (is_send
? channel->select_receive_queue
@@ -50,7 +50,7 @@
}
i = pthread_mutex_unlock (&__go_select_data_mutex);
- assert (i == 0);
+ __go_assert (i == 0);
/* The caller is responsible for signalling the select condition
variable so that the other select knows that something has
@@ -78,21 +78,21 @@
select_cond = channel->select_cond;
i = pthread_mutex_unlock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
- assert (select_mutex != NULL && select_cond != NULL);
+ __go_assert (select_mutex != NULL && select_cond != NULL);
i = pthread_mutex_lock (select_mutex);
- assert (i == 0);
+ __go_assert (i == 0);
i = pthread_cond_broadcast (select_cond);
- assert (i == 0);
+ __go_assert (i == 0);
i = pthread_mutex_unlock (select_mutex);
- assert (i == 0);
+ __go_assert (i == 0);
i = pthread_mutex_lock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
/* Prepare to receive something on a channel. Return true if the
@@ -109,7 +109,7 @@
synched_with_select = 0;
i = pthread_mutex_lock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
while (1)
{
@@ -179,7 +179,7 @@
if (!was_marked)
{
i = pthread_cond_broadcast (&channel->cond);
- assert (i == 0);
+ __go_assert (i == 0);
}
}
}
@@ -205,7 +205,7 @@
again. */
i = pthread_cond_wait (&channel->cond, &channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
}
@@ -223,7 +223,7 @@
/* For a synchronous receiver, we tell the sender that we picked
up the value by setting the next_store field back to 0.
Using the mutexes should implement a memory barrier. */
- assert (channel->next_store == 1);
+ __go_assert (channel->next_store == 1);
channel->next_store = 0;
channel->waiting_to_receive = 0;
@@ -234,7 +234,7 @@
/* This is a broadcast to make sure that a synchronous sender sees
it. */
i = pthread_cond_broadcast (&channel->cond);
- assert (i == 0);
+ __go_assert (i == 0);
__go_unlock_and_notify_selects (channel);
}
@@ -253,16 +253,16 @@
select_cond = channel->select_cond;
i = pthread_mutex_unlock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
if (select_mutex != NULL)
{
i = pthread_mutex_lock (select_mutex);
- assert (i == 0);
+ __go_assert (i == 0);
i = pthread_cond_broadcast (select_cond);
- assert (i == 0);
+ __go_assert (i == 0);
i = pthread_mutex_unlock (select_mutex);
- assert (i == 0);
+ __go_assert (i == 0);
}
}
@@ -273,7 +273,7 @@
{
uint64_t ret;
- assert (channel->element_size <= sizeof (uint64_t));
+ __go_assert (channel->element_size <= sizeof (uint64_t));
if (!__go_receive_acquire (channel, for_select))
return 0;
@@ -4,13 +4,13 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "ffi.h"
#include "go-alloc.h"
+#include "go-assert.h"
#include "go-type.h"
#include "runtime.h"
@@ -260,7 +260,7 @@
rettype = go_func_return_ffi (func);
status = ffi_prep_cif (cif, FFI_DEFAULT_ABI, num_args, rettype, args);
- assert (status == FFI_OK);
+ __go_assert (status == FFI_OK);
}
/* Get the total size required for the result parameters of a
@@ -342,7 +342,7 @@
ffi_cif cif;
unsigned char *call_result;
- assert (func_type->__common.__code == GO_FUNC);
+ __go_assert (func_type->__common.__code == GO_FUNC);
go_func_to_cif (func_type, is_interface, &cif);
call_result = (unsigned char *) malloc (go_results_size (func_type));
@@ -4,7 +4,6 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
#include <pthread.h>
#include <stdarg.h>
#include <stddef.h>
@@ -13,6 +12,7 @@
#include <unistd.h>
#include "config.h"
+#include "go-assert.h"
#include "channel.h"
/* __go_select builds an array of these structures. */
@@ -75,7 +75,7 @@
return 0;
x = pthread_mutex_lock (&__go_select_data_mutex);
- assert (x == 0);
+ __go_assert (x == 0);
while (queue != NULL)
{
@@ -85,7 +85,7 @@
}
x = pthread_mutex_unlock (&__go_select_data_mutex);
- assert (x == 0);
+ __go_assert (x == 0);
return queue != NULL;
}
@@ -195,12 +195,12 @@
struct __go_channel_select *queue;
x = pthread_mutex_lock (&__go_select_data_mutex);
- assert (x == 0);
+ __go_assert (x == 0);
queue = (is_send
? channel->select_receive_queue
: channel->select_send_queue);
- assert (queue != NULL);
+ __go_assert (queue != NULL);
while (queue != NULL)
{
@@ -214,7 +214,7 @@
}
x = pthread_mutex_unlock (&__go_select_data_mutex);
- assert (x == 0);
+ __go_assert (x == 0);
if (queue == NULL)
return 0;
@@ -313,7 +313,7 @@
}
}
- assert (found);
+ __go_assert (found);
}
}
@@ -349,7 +349,7 @@
}
x = pthread_mutex_lock (&channel->lock);
- assert (x == 0);
+ __go_assert (x == 0);
if (is_channel_ready (channel, is_send))
{
@@ -396,7 +396,7 @@
++ready_count;
}
}
- assert (ready_count > 0);
+ __go_assert (ready_count > 0);
return ready_count;
}
@@ -419,7 +419,7 @@
continue;
x = pthread_mutex_unlock (&channel->lock);
- assert (x == 0);
+ __go_assert (x == 0);
}
}
@@ -482,7 +482,7 @@
clear_select_waiting (&channels[j], selected_pointer);
x = pthread_mutex_unlock (&channel->lock);
- assert (x == 0);
+ __go_assert (x == 0);
}
}
@@ -493,13 +493,13 @@
if (needs_broadcast)
{
x = pthread_mutex_lock (&__go_select_mutex);
- assert (x == 0);
+ __go_assert (x == 0);
x = pthread_cond_broadcast (&__go_select_cond);
- assert (x == 0);
+ __go_assert (x == 0);
x = pthread_mutex_unlock (&__go_select_mutex);
- assert (x == 0);
+ __go_assert (x == 0);
}
return ret;
@@ -547,7 +547,7 @@
}
x = pthread_mutex_lock (&channel->lock);
- assert (x == 0);
+ __go_assert (x == 0);
/* To avoid a race condition, we have to check again whether the
channel is ready. It may have become ready since we did the
@@ -564,7 +564,7 @@
selected_for_read_pointer);
x = pthread_mutex_unlock (&channel->lock);
- assert (x == 0);
+ __go_assert (x == 0);
}
return ret;
@@ -686,7 +686,7 @@
to touch SELECTED_CHANNEL here. It must be NULL,
because otherwise that would somebody has promised to
synch up with us and then failed to do so. */
- assert (selected_channel == NULL);
+ __go_assert (selected_channel == NULL);
continue;
}
@@ -713,7 +713,7 @@
for something to happen. */
x = pthread_mutex_lock (&__go_select_mutex);
- assert (x == 0);
+ __go_assert (x == 0);
/* Check whether CHANNEL_SELECTED was set while the channels
were unlocked. If it was set, then we can simply loop around
@@ -726,12 +726,12 @@
signal. */
x = pthread_mutex_lock (&__go_select_data_mutex);
- assert (x == 0);
+ __go_assert (x == 0);
is_selected = selected_channel != NULL;
x = pthread_mutex_unlock (&__go_select_data_mutex);
- assert (x == 0);
+ __go_assert (x == 0);
if (!is_selected)
{
@@ -746,13 +746,13 @@
: &selected_for_read)))
{
x = pthread_cond_wait (&__go_select_cond, &__go_select_mutex);
- assert (x == 0);
+ __go_assert (x == 0);
}
is_queued = 1;
}
x = pthread_mutex_unlock (&__go_select_mutex);
- assert (x == 0);
+ __go_assert (x == 0);
}
}
@@ -4,11 +4,11 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
#include <stdint.h>
#include <pthread.h>
+#include "go-assert.h"
#include "runtime.h"
/* We use a single global lock and condition variable. This is
@@ -57,13 +57,13 @@
/* Lock the mutex. */
i = pthread_mutex_lock (&sem_lock);
- assert (i == 0);
+ __go_assert (i == 0);
/* Check the count again with the mutex locked. */
if (acquire (addr))
{
i = pthread_mutex_unlock (&sem_lock);
- assert (i == 0);
+ __go_assert (i == 0);
return;
}
@@ -72,11 +72,11 @@
acquire the mutex and block, so we are sure to see the signal
of the condition variable. */
i = pthread_cond_wait (&sem_cond, &sem_lock);
- assert (i == 0);
+ __go_assert (i == 0);
/* Unlock the mutex and try again. */
i = pthread_mutex_unlock (&sem_lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
}
@@ -95,7 +95,7 @@
/* VAL is the old value. It should never be negative. If it is
negative, that implies that Semacquire somehow decremented a zero
value, or that the count has overflowed. */
- assert (val >= 0);
+ __go_assert (val >= 0);
/* If the old value was zero, then we have now released a count, and
we signal the condition variable. If the old value was positive,
@@ -108,12 +108,12 @@
int i;
i = pthread_mutex_lock (&sem_lock);
- assert (i == 0);
+ __go_assert (i == 0);
i = pthread_cond_broadcast (&sem_cond);
- assert (i == 0);
+ __go_assert (i == 0);
i = pthread_mutex_unlock (&sem_lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
}
@@ -5,7 +5,6 @@
license that can be found in the LICENSE file. */
#include <stdint.h>
-#include <assert.h>
#include "channel.h"
@@ -5,7 +5,6 @@
license that can be found in the LICENSE file. */
#include <stdint.h>
-#include <assert.h>
#include "channel.h"
@@ -5,8 +5,8 @@
license that can be found in the LICENSE file. */
#include <stdint.h>
-#include <assert.h>
+#include "go-assert.h"
#include "go-panic.h"
#include "channel.h"
@@ -19,12 +19,12 @@
_Bool has_space;
i = pthread_mutex_lock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
while (channel->selected_for_send)
{
i = pthread_cond_wait (&channel->cond, &channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
if (channel->is_closed)
@@ -33,11 +33,11 @@
if (channel->closed_op_count >= MAX_CLOSED_OPERATIONS)
{
i = pthread_mutex_unlock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
__go_panic_msg ("too many operations on closed channel");
}
i = pthread_mutex_unlock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
return SEND_NONBLOCKING_ACQUIRE_CLOSED;
}
@@ -78,14 +78,14 @@
if (has_space)
{
channel->waiting_to_send = 1;
- assert (channel->next_store == 0);
+ __go_assert (channel->next_store == 0);
}
}
if (!has_space)
{
i = pthread_mutex_unlock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
return SEND_NONBLOCKING_ACQUIRE_NOSPACE;
}
@@ -98,7 +98,7 @@
_Bool
__go_send_nonblocking_small (struct __go_channel *channel, uint64_t val)
{
- assert (channel->element_size <= sizeof (uint64_t));
+ __go_assert (channel->element_size <= sizeof (uint64_t));
int data = __go_send_nonblocking_acquire (channel);
if (data != SEND_NONBLOCKING_ACQUIRE_SPACE)
@@ -5,8 +5,8 @@
license that can be found in the LICENSE file. */
#include <stdint.h>
-#include <assert.h>
+#include "go-assert.h"
#include "go-panic.h"
#include "channel.h"
@@ -21,7 +21,7 @@
int i;
i = pthread_mutex_lock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
while (1)
{
@@ -32,7 +32,7 @@
if (channel->closed_op_count >= MAX_CLOSED_OPERATIONS)
{
i = pthread_mutex_unlock (&channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
__go_panic_msg ("too many operations on closed channel");
}
channel->selected_for_send = 0;
@@ -53,7 +53,7 @@
receiver. */
if (!channel->waiting_to_send)
{
- assert (channel->next_store == 0);
+ __go_assert (channel->next_store == 0);
return 1;
}
}
@@ -70,7 +70,7 @@
again. */
i = pthread_cond_wait (&channel->cond, &channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
}
@@ -88,7 +88,7 @@
channel->next_store = (channel->next_store + 1) % channel->num_entries;
i = pthread_cond_signal (&channel->cond);
- assert (i == 0);
+ __go_assert (i == 0);
}
else
{
@@ -104,7 +104,7 @@
waiting on the condition, but senders won't send another
signal. */
i = pthread_cond_broadcast (&channel->cond);
- assert (i == 0);
+ __go_assert (i == 0);
/* Wait until the value is received. */
synched_with_select = 0;
@@ -126,7 +126,7 @@
}
i = pthread_cond_wait (&channel->cond, &channel->lock);
- assert (i == 0);
+ __go_assert (i == 0);
}
channel->waiting_to_send = 0;
@@ -138,7 +138,7 @@
receivers might be waiting, but only senders will be able to
act. */
i = pthread_cond_broadcast (&channel->cond);
- assert (i == 0);
+ __go_assert (i == 0);
}
channel->selected_for_send = 0;
@@ -151,7 +151,7 @@
void
__go_send_small (struct __go_channel *channel, uint64_t val, _Bool for_select)
{
- assert (channel->element_size <= sizeof (uint64_t));
+ __go_assert (channel->element_size <= sizeof (uint64_t));
if (!__go_send_acquire (channel, for_select))
return;
@@ -4,10 +4,10 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
#include <signal.h>
#include <stdlib.h>
+#include "go-assert.h"
#include "go-panic.h"
#include "go-signal.h"
@@ -135,9 +135,9 @@
/* The signal handler blocked signals; unblock them. */
i = sigfillset (&clear);
- assert (i == 0);
+ __go_assert (i == 0);
i = sigprocmask (SIG_UNBLOCK, &clear, NULL);
- assert (i == 0);
+ __go_assert (i == 0);
__go_panic_msg (msg);
}
@@ -158,7 +158,7 @@
sa.sa_handler = SIG_DFL;
i = sigemptyset (&sa.sa_mask);
- assert (i == 0);
+ __go_assert (i == 0);
if (sigaction (sig, &sa, NULL) != 0)
abort ();
@@ -186,9 +186,9 @@
sa.sa_handler = sighandler;
i = sigfillset (&sa.sa_mask);
- assert (i == 0);
+ __go_assert (i == 0);
for (i = 0; signals[i].sig != -1; ++i)
if (sigaction (signals[i].sig, &sa, NULL) != 0)
- assert (0);
+ __go_assert (0);
}
@@ -6,7 +6,6 @@
#include "config.h"
-#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <unistd.h>
@@ -16,6 +15,7 @@
#endif
#include "go-alloc.h"
+#include "go-assert.h"
/* In order to build a trampoline we need space which is both writable
and executable. We currently just allocate a whole page. This
@@ -29,7 +29,7 @@
size_t off;
page_size = getpagesize ();
- assert (page_size >= size);
+ __go_assert (page_size >= size);
ret = __go_alloc (2 * page_size - 1);
ret = (void *) (((uintptr_t) ret + page_size - 1)
& ~ ((uintptr_t) page_size - 1));
@@ -38,14 +38,14 @@
offsets, we need to ensure that it will see the closure
address. */
off = ((size + sizeof (void *) - 1) / sizeof (void *)) * sizeof (void *);
- assert (size + off + sizeof (void *) <= page_size);
+ __go_assert (size + off + sizeof (void *) <= page_size);
__builtin_memcpy (ret + off, &closure, sizeof (void *));
#ifdef HAVE_SYS_MMAN_H
{
int i;
i = mprotect (ret, size, PROT_READ | PROT_WRITE | PROT_EXEC);
- assert (i == 0);
+ __go_assert (i == 0);
}
#endif
@@ -73,7 +73,7 @@
mstats.by_size[sizeclass].nmalloc++;
if(!mlookup(v, nil, nil, nil, &ref)) {
- printf("malloc %lld; mlookup failed\n", (long long)size);
+ //printf("malloc %lld; mlookup failed\n", (long long)size);
throw("malloc mlookup");
}
*ref = RefNone | refflag;
@@ -145,7 +145,7 @@
throw("malloc/free - deadlock");
if(!mlookup(v, nil, nil, &s, &ref)) {
- printf("free %p: not an allocated block\n", v);
+ //printf("free %p: not an allocated block\n", v);
throw("free mlookup");
}
prof = *ref & RefProfiled;
@@ -228,11 +228,11 @@
if(0) {
nobj = (s->npages << PageShift) / (n + RefcountOverhead);
if((byte*)s->gcref < p || (byte*)(s->gcref+nobj) > p+(s->npages<<PageShift)) {
- printf("odd span state=%d span=%p base=%p sizeclass=%d n=%llu size=%llu npages=%llu\n",
- s->state, s, p, s->sizeclass, (unsigned long long)nobj, (unsigned long long)n, (unsigned long long)s->npages);
- printf("s->base sizeclass %d v=%p base=%p gcref=%p blocksize=%llu nobj=%llu size=%llu end=%p end=%p\n",
- s->sizeclass, v, p, s->gcref, (unsigned long long)s->npages<<PageShift,
- (unsigned long long)nobj, (unsigned long long)n, s->gcref + nobj, p+(s->npages<<PageShift));
+ //printf("odd span state=%d span=%p base=%p sizeclass=%d n=%llu size=%llu npages=%llu\n",
+ // s->state, s, p, s->sizeclass, (unsigned long long)nobj, (unsigned long long)n, (unsigned long long)s->npages);
+ //printf("s->base sizeclass %d v=%p base=%p gcref=%p blocksize=%llu nobj=%llu size=%llu end=%p end=%p\n",
+ // s->sizeclass, v, p, s->gcref, (unsigned long long)s->npages<<PageShift,
+ // (unsigned long long)nobj, (unsigned long long)n, s->gcref + nobj, p+(s->npages<<PageShift));
throw("bad gcref");
}
}
@@ -298,23 +298,23 @@
const FuncType *ft;
if(obj.__type_descriptor == nil) {
- printf("runtime.SetFinalizer: first argument is nil interface\n");
+ //printf("runtime.SetFinalizer: first argument is nil interface\n");
throw:
throw("runtime.SetFinalizer");
}
if(obj.__type_descriptor->__code != GO_PTR) {
- printf("runtime.SetFinalizer: first argument is %.*s, not pointer\n", (int)obj.__type_descriptor->__reflection->__length, obj.__type_descriptor->__reflection->__data);
+ //printf("runtime.SetFinalizer: first argument is %.*s, not pointer\n", (int)obj.__type_descriptor->__reflection->__length, obj.__type_descriptor->__reflection->__data);
goto throw;
}
if(!mlookup(obj.__object, &base, &size, nil, nil) || obj.__object != base) {
- printf("runtime.SetFinalizer: pointer not at beginning of allocated block\n");
+ //printf("runtime.SetFinalizer: pointer not at beginning of allocated block\n");
goto throw;
}
ft = nil;
if(finalizer.__type_descriptor != nil) {
if(finalizer.__type_descriptor->__code != GO_FUNC) {
badfunc:
- printf("runtime.SetFinalizer: second argument is %.*s, not func(%.*s)\n", (int)finalizer.__type_descriptor->__reflection->__length, finalizer.__type_descriptor->__reflection->__data, (int)obj.__type_descriptor->__reflection->__length, obj.__type_descriptor->__reflection->__data);
+ //printf("runtime.SetFinalizer: second argument is %.*s, not func(%.*s)\n", (int)finalizer.__type_descriptor->__reflection->__length, finalizer.__type_descriptor->__reflection->__data, (int)obj.__type_descriptor->__reflection->__length, obj.__type_descriptor->__reflection->__data);
goto throw;
}
ft = (const FuncType*)finalizer.__type_descriptor;
@@ -322,7 +322,7 @@
goto badfunc;
if(getfinalizer(obj.__object, 0)) {
- printf("runtime.SetFinalizer: finalizer already set");
+ //printf("runtime.SetFinalizer: finalizer already set");
goto throw;
}
}
@@ -254,7 +254,7 @@
MSpan *t;
if(s->state != MSpanInUse || s->ref != 0) {
- printf("MHeap_FreeLocked - span %p ptr %zu state %u ref %u\n", s, (size_t) (s->start<<PageShift), (unsigned int) s->state, (unsigned int) s->ref);
+ // printf("MHeap_FreeLocked - span %p ptr %zu state %u ref %u\n", s, (size_t) (s->start<<PageShift), (unsigned int) s->state, (unsigned int) s->ref);
throw("MHeap_FreeLocked - invalid free");
}
s->state = MSpanFree;
@@ -103,7 +103,7 @@
sizeclass++;
}
if(sizeclass != NumSizeClasses) {
- printf("sizeclass=%d NumSizeClasses=%d\n", sizeclass, NumSizeClasses);
+ // printf("sizeclass=%d NumSizeClasses=%d\n", sizeclass, NumSizeClasses);
throw("InitSizes - bad NumSizeClasses");
}
@@ -122,13 +122,13 @@
for(n=0; n < MaxSmallSize; n++) {
sizeclass = SizeToClass(n);
if(sizeclass < 1 || sizeclass >= NumSizeClasses || class_to_size[sizeclass] < n) {
- printf("size=%d sizeclass=%d class_to_size=%d\n", n, sizeclass, class_to_size[sizeclass]);
- printf("incorrect SizeToClass");
+ // printf("size=%d sizeclass=%d class_to_size=%d\n", n, sizeclass, class_to_size[sizeclass]);
+ // printf("incorrect SizeToClass");
goto dump;
}
if(sizeclass > 1 && class_to_size[sizeclass-1] >= n) {
- printf("size=%d sizeclass=%d class_to_size=%d\n", n, sizeclass, class_to_size[sizeclass]);
- printf("SizeToClass too big");
+ // printf("size=%d sizeclass=%d class_to_size=%d\n", n, sizeclass, class_to_size[sizeclass]);
+ // printf("SizeToClass too big");
goto dump;
}
}
@@ -150,7 +150,7 @@
return;
dump:
- if(1){
+ if(0){
printf("NumSizeClasses=%d\n", NumSizeClasses);
printf("class_to_size:");
for(sizeclass=0; sizeclass<NumSizeClasses; sizeclass++)
@@ -4,12 +4,12 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
-#include <assert.h>
-
#include <rtems/error.h>
#include <rtems/system.h>
#include <rtems/rtems/tasks.h>
+#include "go-assert.h"
+
/* RTEMS does not support GNU TLS extension __thread. */
void
__wrap_rtems_task_variable_add (void **var)
@@ -18,7 +18,7 @@
if (sc != RTEMS_SUCCESSFUL)
{
rtems_error (sc, "rtems_task_variable_add failed");
- assert (0);
+ __go_assert (0);
}
}
@@ -7,7 +7,7 @@
#include "config.h"
#define _GNU_SOURCE
-#include <assert.h>
+#include "go-assert.h"
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -114,7 +114,7 @@
#define USED(v) ((void) v)
/* We map throw to assert. */
-#define throw(s) assert(s == 0)
+#define throw(s) __go_assert(s == 0)
void* mal(uintptr);
void mallocinit(void);