Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ac.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
extern "C" {
#endif

#ifndef _MSC_VER
#define AC_EXPORT __attribute__ ((visibility ("default")))
#else
#define AC_EXPORT
#endif

/* If the subject-string doesn't match any of the given patterns, "match_begin"
* should be a negative; otherwise the substring of the subject-string,
Expand Down
17 changes: 12 additions & 5 deletions ac_fast.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ AC_Converter::Calc_State_Sz(const ACS_State* s) const {
if (sz < sizeof(AC_State))
sz = sizeof(AC_State);

uint32 align = __alignof__(dummy);
uint32 align = __alignof(dummy);
sz = (sz + align - 1) & ~(align - 1);
return sz;
}
Expand All @@ -35,14 +35,14 @@ AC_Converter::Alloc_Buffer() {
root_goto_ofst = 0;

// part 3: mapping of state's relative position.
unsigned align = __alignof__(AC_Ofst);
unsigned align = __alignof(AC_Ofst);
sz = (sz + align - 1) & ~(align - 1);
states_ofst_ofst = sz;

sz += sizeof(AC_Ofst) * all_states.size();

// part 4: state's contents
align = __alignof__(AC_State);
align = __alignof(AC_State);
sz = (sz + align - 1) & ~(align - 1);
first_state_ofst = sz;

Expand Down Expand Up @@ -82,7 +82,7 @@ AC_Converter::Populate_Root_Goto_Func(AC_Buffer* buf,
uint32 new_id = 1;
bool full_fantout = (goto_vect.size() == 255);
if (likely(!full_fantout))
bzero(root_gotos, 256*sizeof(InputTy));
memset(root_gotos, 0, 256 * sizeof(InputTy));

for (GotoVect::iterator i = goto_vect.begin(), e = goto_vect.end();
i != e; i++, new_id++) {
Expand Down Expand Up @@ -212,7 +212,14 @@ Get_State_Addr(unsigned char* buf_base, AC_Ofst* StateOfstVect, uint32 state_id)
// 10+ benchmarks. It's still too early to say which one works better.
//
#if !defined(BS_MULTI_VER)
static bool __attribute__((always_inline)) inline

#ifdef _MSC_VER
#define INLINE_FLAG inline __forceinline
#else
#define INLINE_FLAG inline __attribute__((always_inline))
#endif

static bool INLINE_FLAG
Binary_Search_Input(InputTy* input_vect, int vect_len, InputTy input, int& idx) {
if (vect_len <= 8) {
for (int i = 0; i < vect_len; i++) {
Expand Down
3 changes: 1 addition & 2 deletions ac_slow.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <ctype.h>
#include <strings.h> // for bzero
#include <algorithm>
#include "ac_slow.hpp"
#include "ac.h"
Expand All @@ -13,7 +12,7 @@
ACS_Constructor::ACS_Constructor() : _next_node_id(1) {
_root = new_state();
_root_char = new InputTy[256];
bzero((void*)_root_char, 256);
memset((void*)_root_char, 0, 256 * sizeof(InputTy));

#ifdef VERIFY
_pattern_buf = 0;
Expand Down
5 changes: 5 additions & 0 deletions ac_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ typedef unsigned char InputTy;
#define ASSERT(c) ((void)0)
#endif

#ifndef _MSC_VER
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
#else
#define likely(x) (x)
#define unlikely(x) (x)
#endif

#ifndef offsetof
#define offsetof(st, m) ((size_t)(&((st *)0)->m))
Expand Down