Skip to content

Commit

Permalink
Blueprint 'unmmap-after-fork': review comments.
Browse files Browse the repository at this point in the history
Make a system specific check for MAP_ANONYMOUS
part of configuration process.
Follow up on a broken ENABLE_BACKTRACE switch
and fix a few cases which didn't compile with it.
  • Loading branch information
kostja committed Feb 15, 2011
1 parent a20faa7 commit b5b3a2b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.6)
project(Tarantool)
include(CheckLibraryExists)
include(CheckIncludeFile)
include(CheckSymbolExists)
find_program(ECHO echo)
find_program(CAT cat)
find_program(GIT git)
Expand Down Expand Up @@ -36,6 +37,9 @@ else()
message (FATAL_ERROR "Unsupported platform -- ${CMAKE_SYSTEM_NAME}")
endif()

check_symbol_exists(MAP_ANON sys/mman.h HAVE_MAP_ANON)
check_symbol_exists(MAP_ANONYMOUS sys/mman.h HAVE_MAP_ANONYMOUS)

#
# Tarantool uses 'coro' (coroutines) library # to implement
# cooperative multi-tasking. Since coro.h is included
Expand Down
5 changes: 1 addition & 4 deletions core/coro.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* SUCH DAMAGE.
*/

#include "config.h"
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
Expand All @@ -33,10 +34,6 @@
#include <coro.h>
#include <palloc.h>

#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif

struct tarantool_coro *
tarantool_coro_create(struct tarantool_coro *coro, void (*f) (void *), void *data)
{
Expand Down
8 changes: 3 additions & 5 deletions core/fiber.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* SUCH DAMAGE.
*/

#include "config.h"
#include <fiber.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
Expand All @@ -42,7 +44,6 @@
#include <third_party/queue.h>
#include <third_party/khash.h>

#include <fiber.h>
#include <palloc.h>
#include <salloc.h>
#include <say.h>
Expand Down Expand Up @@ -93,7 +94,7 @@ static void
update_last_stack_frame(struct fiber *fiber)
{
#ifdef ENABLE_BACKTRACE
fiber->last_stack_frame = frame_addess();
fiber->last_stack_frame = __builtin_frame_address(0);
#else
(void)fiber;
#endif /* ENABLE_BACKTRACE */
Expand Down Expand Up @@ -335,9 +336,6 @@ fiber_loop(void *data __unused__)
}
}

#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif

/* fiber never dies, just become zombie */
struct fiber *
Expand Down
1 change: 1 addition & 0 deletions core/salloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* SUCH DAMAGE.
*/

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Expand Down
11 changes: 11 additions & 0 deletions include/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
* Set if the system has bfd.h header and GNU bfd library.
*/
#cmakedefine HAVE_BFD 1
#cmakedefine HAVE_MAP_ANON 1
#cmakedefine HAVE_MAP_ANONYMOUS 1
#if !defined(HAVE_MAP_ANONYMOUS) && defined(HAVE_MAP_ANON)
/*
* MAP_ANON is deprecated, MAP_ANONYMOUS should be used instead.
* Unfortunately, it's not universally present (e.g. not present
* on FreeBSD.
*/
#define MAP_ANONYMOUS MAP_ANON
#endif

/*
* vim: syntax=c
*/
Expand Down
3 changes: 2 additions & 1 deletion include/fiber.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#ifndef TARANTOOL_FIBER_H
#define TARANTOOL_FIBER_H

#include "config.h"
#include <stdint.h>
#include <unistd.h>
#include <sys/uio.h>
Expand Down Expand Up @@ -55,7 +56,7 @@ struct ring {

struct fiber {
ev_io io;
#ifdef BACKTRACE
#ifdef ENABLE_BACKTRACE
void *last_stack_frame;
#endif
int csw;
Expand Down
5 changes: 0 additions & 5 deletions include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,4 @@ void assert_fail(const char *assertion, const char *file,
unsigned int line, const char *function) __attribute__ ((noreturn));
#endif

#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif


#endif

0 comments on commit b5b3a2b

Please sign in to comment.