Skip to content

Commit

Permalink
Merge pull request #959 from eisenhauer/AtlUpstream
Browse files Browse the repository at this point in the history
Atl upstream
  • Loading branch information
eisenhauer committed Oct 26, 2018
2 parents 7d70a48 + 5e4b083 commit 5f1e133
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 51 deletions.
44 changes: 21 additions & 23 deletions thirdparty/atl/atl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
cmake_minimum_required(VERSION 3.0)

project(ATL C)
set(ATL_VERSION_MAJOR 2)
set(ATL_VERSION_MINOR 2)
set(ATL_VERSION_PATCH 1)
set(ATL_VERSION
${ATL_VERSION_MAJOR}.${ATL_VERSION_MINOR}.${ATL_VERSION_PATCH})
project(ATL VERSION 2.2.1 LANGUAGES C)

# Some boilerplate to setup nice output directories
set(CMAKE_INSTALL_BINDIR bin CACHE STRING "Installation runtime subdirectory")
Expand Down Expand Up @@ -95,23 +90,17 @@ mark_as_advanced(ATL_ATOM_SERVER_HOST)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config.h)

# Set up include-directories
include_directories(
"${PROJECT_SOURCE_DIR}" # to find foo/foo.h
"${PROJECT_BINARY_DIR}") # to find foo/config.h

set(ATL_LIBRARY_PREFIX "" CACHE STRING
"Prefix to prepend to the output library name")
mark_as_advanced(ATL_LIBRARY_PREFIX)

add_library(atl atom.c attr.c lookup3.c tclHash.c)
add_library(atl::atl ALIAS atl)
set_target_properties(atl PROPERTIES
OUTPUT_NAME ${ATL_LIBRARY_PREFIX}atl
VERSION ${ATL_VERSION}
SOVERSION ${ATL_VERSION_MAJOR}
PUBLIC_HEADER atl.h)
add_library(atl::atl ALIAS atl)

target_include_directories(atl PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
Expand Down Expand Up @@ -174,24 +163,33 @@ if(BUILD_TESTING)
endif()

# Setup packaging and configs
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/atl-config-version.cmake"
COMPATIBILITY SameMajorVersion)
configure_file(
atl-config.cmake.in
"${PROJECT_BINARY_DIR}/atl-config.cmake"
@ONLY)

# Add all targets to the build-tree export set
export(TARGETS atl NAMESPACE atl::
FILE "${PROJECT_BINARY_DIR}/atl-targets.cmake")
configure_file(atl-config.cmake.in
"${PROJECT_BINARY_DIR}/atl-config.cmake" @ONLY)
configure_file(atl-config-version.cmake.in
"${PROJECT_BINARY_DIR}/atl-config-version.cmake" @ONLY)

# Install the atl-config.cmake and atl-config-version.cmake
install(FILES
"${PROJECT_BINARY_DIR}/atl-config.cmake"
"${PROJECT_BINARY_DIR}/atl-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" COMPONENT dev)
install(
FILES
"${PROJECT_BINARY_DIR}/atl-config.cmake"
"${PROJECT_BINARY_DIR}/atl-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
COMPONENT dev)

# Install the export set for use with the install-tree
install(EXPORT atl-targets NAMESPACE atl::
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" COMPONENT dev)
install(
EXPORT atl-targets
NAMESPACE atl::
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
COMPONENT dev)

set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/atl.supp)

Expand Down
15 changes: 0 additions & 15 deletions thirdparty/atl/atl/atl-config-version.cmake.in

This file was deleted.

14 changes: 1 addition & 13 deletions thirdparty/atl/atl/atl-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
# - Config file for the Atl package
#
# It defines the following variables
# ATL_INCLUDE_DIRS - include directories for Atl
# ATL_LIBRARIES - libraries to link against
#
# And the following imported targets:
# atl::atl
#

include("${CMAKE_CURRENT_LIST_DIR}/atl-config-version.cmake")

include(FindPackageHandleStandardArgs)
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG "${CMAKE_CURRENT_LIST_FILE}")
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE})
find_package_handle_standard_args(${CMAKE_FIND_PACKAGE_NAME} CONFIG_MODE)

if(NOT TARGET atl::atl)
Expand Down
3 changes: 3 additions & 0 deletions thirdparty/atl/atl/atl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ extern
atom_server
init_atom_server (atom_cache_type cache_style);

extern void
free_atom_server(atom_server as);

extern
char *
get_server_id (atom_server as);
Expand Down
20 changes: 20 additions & 0 deletions thirdparty/atl/atl/atom.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
# include <malloc.h>
# endif
# include <stdio.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
# include <errno.h>
# include <sys/types.h>
# ifndef HAVE_WINDOWS_H
Expand Down Expand Up @@ -573,6 +575,24 @@ preload_in_use_atoms(atom_server as)
(void) atom_from_string(as, in_use_values[i++]);
}
}

void
free_atom_server(atom_server as)
{
Tcl_HashSearch search;
Tcl_HashEntry * entry = Tcl_FirstHashEntry(&as->string_hash_table, &search);
while (entry) {
send_get_atom_msg_ptr stored;
stored = Tcl_GetHashValue(entry);
free(stored->atom_string);
free(stored);
entry = Tcl_NextHashEntry(&search);
}
Tcl_DeleteHashTable(&as->string_hash_table);
Tcl_DeleteHashTable(&as->value_hash_table);
free(as);
}

atom_server
init_atom_server(cache_style)
atom_cache_type cache_style;
Expand Down
3 changes: 3 additions & 0 deletions thirdparty/atl/atl/atom_server.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <errno.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#ifndef HAVE_WINDOWS_H
#include <sys/socket.h>
Expand Down
16 changes: 16 additions & 0 deletions thirdparty/atl/atl/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,30 @@ extern int
add_pattr(attr_list list, atom_t attr_id, attr_value_type val_type,
attr_union value);

static void
deallocate_global_atom_server()
{
if (global_as) {
atom_server tmp = global_as;
global_as = NULL;
free_atom_server(tmp);
}
}

static
void
init_global_atom_server(asp)
atom_server *asp;
{
static int first = 1;
if (*asp != NULL) return;

*asp = init_atom_server(prefill_atom_cache);

if ((asp == &global_as) && first) {
first = 0;
atexit(deallocate_global_atom_server);
}
}

attr_list
Expand Down
2 changes: 2 additions & 0 deletions thirdparty/atl/atl/lookup3.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
#include "config.h"
#include <stdio.h> /* defines printf for tests */
#include <inttypes.h> /* defines uint32_t etc */
#ifndef _MSC_VER
#include <sys/param.h> /* attempt to define endianness */
#endif
#ifdef linux
# include <endian.h> /* attempt to define endianness */
#endif
Expand Down

0 comments on commit 5f1e133

Please sign in to comment.