Make the absence of perf-cppflags give a good default build.

Defaults are now:
- thread-safe with GCC/Clang
- Debugging not enabled (enable with -UNDEBUG)
pull/13171/head
Josh Haberman 11 years ago
parent cf2a959fa1
commit d869097400
  1. 12
      Makefile
  2. 2
      upb/refcounted.c
  3. 11
      upb/refcounted.h
  4. 1
      upb/table.c

@ -7,17 +7,13 @@
#
# Summary of compiler flags you may want to use:
#
# * -DNDEBUG: makes binary smaller and faster by removing sanity checks.
# * -O3: optimize for maximum speed
# * -UNDEBUG: enables assertions() (makes binary larger and slower)
# * -O0: disable optimizations
# * -g: enable debug symbols
# * -fomit-frame-pointer: makes code smaller and faster by freeing up a reg.
#
# Threading:
# * -DUPB_USE_PTHREADS: configures upb to use pthreads r/w lock.
# * -DUPB_THREAD_UNSAFE: remove all thread-safety.
# * -pthread: required on GCC to enable pthreads (but what does it do?)
#
# Other:
# * -DUPB_UNALIGNED_READS_OK: makes code smaller, but not standard compliant
.PHONY: all lib clean tests test benchmarks benchmark descriptorgen
.PHONY: clean_leave_profile
@ -49,7 +45,7 @@ CXX=g++
CFLAGS=-std=gnu99
CXXFLAGS=
INCLUDE=-Itests -I.
CPPFLAGS=$(INCLUDE) -Wall -Wextra -Wno-sign-compare $(USER_CFLAGS)
CPPFLAGS=$(INCLUDE) -DNDEBUG -Wall -Wextra -Wno-sign-compare $(USER_CFLAGS)
LDLIBS=-lpthread upb/libupb.a
LUA=lua # 5.1 and 5.2 should both be supported

@ -35,7 +35,7 @@ const void *UPB_UNTRACKED_REF = &untracked_val;
static void atomic_inc(uint32_t *a) { (*a)++; }
static bool atomic_dec(uint32_t *a) { return --(*a) == 0; }
#elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || __GNUC__ > 4 ///////////////////
#elif defined(__GNUC__) || defined(__clang__) //////////////////////////////////
static void atomic_inc(uint32_t *a) { __sync_fetch_and_add(a, 1); }
static bool atomic_dec(uint32_t *a) { return __sync_sub_and_fetch(a, 1) == 0; }

@ -21,10 +21,13 @@
#include "upb/table.int.h"
// Reference tracking is designed to be used with a tool like Valgrind; when
// enabled, it will cause reference leaks to show up as actual memory leaks
// that are attributed to the code that leaked the ref, *not* the code that
// originally created the object.
// Reference tracking will check ref()/unref() operations to make sure the
// ref ownership is correct. Where possible it will also make tools like
// Valgrind attribute ref leaks to the code that took the leaked ref, not
// the code that originally created the object.
//
// Enabling this requires the application to define upb_lock()/upb_unlock()
// functions that acquire/release a global mutex (or #define UPB_THREAD_UNSAFE).
#ifndef NDEBUG
#define UPB_DEBUG_REFS
#endif

@ -112,6 +112,7 @@ static bool lookup(const upb_table *t, upb_tabkey key, upb_value *v,
// The given key must not already exist in the table.
static void insert(upb_table *t, upb_tabkey key, upb_value val,
hashfunc_t *hash, eqlfunc_t *eql) {
UPB_UNUSED(eql);
assert(findentry(t, key, hash, eql) == NULL);
assert(val.ctype == t->ctype);
t->count++;

Loading…
Cancel
Save