Skip to content

Commit

Permalink
Put min() in utils
Browse files Browse the repository at this point in the history
Signed-off-by: Morgan Douglas <[email protected]>
  • Loading branch information
morgando committed Oct 21, 2024
1 parent 8de87ad commit 82b145e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion db/eventlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "logmsg.h"
#include "thread_stats.h"
#include "dbinc/locker_info.h"
#include "math_util.h" /* min */

#include "cson.h"
#include "comdb2_atomic.h"
Expand All @@ -64,7 +65,6 @@ static int64_t eventlog_count = 0;
static int eventlog_debug_events = 0;

static void eventlog_roll(void);
#define min(x, y) ((x) < (y) ? (x) : (y))

struct sqltrack {
char fingerprint[FINGERPRINTSZ];
Expand Down
25 changes: 25 additions & 0 deletions util/math_util.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Copyright 2024 Bloomberg Finance L.P.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef __MATH_UTIL_H__
#define __MATH_UTIL_H__

#define min(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })

#endif
2 changes: 1 addition & 1 deletion util/object_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
#include "object_pool.h"
#include "logmsg.h"
#include "sys_wrap.h"
#include "math_util.h" /* min */

#include <mem_util.h>
#include <mem_override.h>

// macros
//#define OBJ_POOL_DEBUG
#define min(x, y) ((x) < (y) ? (x) : (y))
#define full(op) ((op)->nobjs == (op)->capacity)
#define empty(op) ((op)->nobjs == 0)
#define exhausted(op) ((op)->nactiveobjs == (op)->nobjs)
Expand Down

0 comments on commit 82b145e

Please sign in to comment.