diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp
index dd37326..97eb045 100644
--- libgomp/ChangeLog.gomp
+++ libgomp/ChangeLog.gomp
@@ -1,5 +1,9 @@
 2014-12-17  Thomas Schwinge  <thomas@codesourcery.com>
 
+	* libgomp_g.h: Move internal stuff from here...
+	* libgomp_target.h: ..., and here...
+	* libgomp.h: ... into here.
+
 	* Makefile.am: Don't add ../include/gomp-constants.h to
 	nodist_libsubinclude_HEADERS.
 
diff --git libgomp/libgomp.h libgomp/libgomp.h
index dbf1628..78de0b4 100644
--- libgomp/libgomp.h
+++ libgomp/libgomp.h
@@ -632,6 +632,173 @@ extern void gomp_free_thread (void *);
 extern void gomp_init_targets_once (void);
 extern int gomp_get_num_devices (void);
 
+#include "libgomp_target.h"
+#include "splay-tree.h"
+
+struct target_mem_desc {
+  /* Reference count.  */
+  uintptr_t refcount;
+  /* All the splay nodes allocated together.  */
+  splay_tree_node array;
+  /* Start of the target region.  */
+  uintptr_t tgt_start;
+  /* End of the targer region.  */
+  uintptr_t tgt_end;
+  /* Handle to free.  */
+  void *to_free;
+  /* Previous target_mem_desc.  */
+  struct target_mem_desc *prev;
+  /* Number of items in following list.  */
+  size_t list_count;
+
+  /* Corresponding target device descriptor.  */
+  struct gomp_device_descr *device_descr;
+
+  /* Memory mapping info for the thread that created this descriptor.  */
+  struct gomp_memory_mapping *mem_map;
+
+  /* List of splay keys to remove (or decrease refcount)
+     at the end of region.  */
+  splay_tree_key list[];
+};
+
+#define TARGET_CAP_SHARED_MEM	1
+#define TARGET_CAP_NATIVE_EXEC	2
+#define TARGET_CAP_OPENMP_400	4
+#define TARGET_CAP_OPENACC_200	8
+
+/* Information about mapped memory regions (per device/context).  */
+
+struct gomp_memory_mapping
+{
+  /* Splay tree containing information about mapped memory regions.  */
+  struct splay_tree_s splay_tree;
+
+  /* Mutex for operating with the splay tree and other shared structures.  */
+  gomp_mutex_t lock;
+
+  /* True when tables have been added to this memory map.  */
+  bool is_initialized;
+};
+
+typedef struct acc_dispatch_t
+{
+  /* This is a linked list of data mapped using the
+     acc_map_data/acc_unmap_data or "acc enter data"/"acc exit data" pragmas
+     (TODO).  Unlike mapped_data in the goacc_thread struct, unmapping can
+     happen out-of-order with respect to mapping.  */
+  struct target_mem_desc *data_environ;
+
+  /* Open or close a device instance.  */
+  void *(*open_device_func) (int n);
+  int (*close_device_func) (void *h);
+
+  /* Set or get the device number.  */
+  int (*get_device_num_func) (void);
+  void (*set_device_num_func) (int);
+
+  /* Execute.  */
+  void (*exec_func) (void (*) (void *), size_t, void **, void **, size_t *,
+		     unsigned short *, int, int, int, int, void *);
+
+  /* Async cleanup callback registration.  */
+  void (*register_async_cleanup_func) (void *);
+
+  /* Asynchronous routines.  */
+  int (*async_test_func) (int);
+  int (*async_test_all_func) (void);
+  void (*async_wait_func) (int);
+  void (*async_wait_async_func) (int, int);
+  void (*async_wait_all_func) (void);
+  void (*async_wait_all_async_func) (int);
+  void (*async_set_async_func) (int);
+
+  /* Create/destroy TLS data.  */
+  void *(*create_thread_data_func) (void *);
+  void (*destroy_thread_data_func) (void *);
+
+  /* NVIDIA target specific routines.  */
+  struct {
+    void *(*get_current_device_func) (void);
+    void *(*get_current_context_func) (void);
+    void *(*get_stream_func) (int);
+    int (*set_stream_func) (int, void *);
+  } cuda;
+} acc_dispatch_t;
+
+/* This structure describes accelerator device.
+   It contains name of the corresponding libgomp plugin, function handlers for
+   interaction with the device, ID-number of the device, and information about
+   mapped memory.  */
+struct gomp_device_descr
+{
+  /* The name of the device.  */
+  const char *name;
+
+  /* Capabilities of device (supports OpenACC, OpenMP).  */
+  unsigned int capabilities;
+
+  /* This is the ID number of device.  It could be specified in DEVICE-clause of
+     TARGET construct.  */
+  int id;
+
+  /* This is the ID number of device among devices of the same type.  */
+  int target_id;
+
+  /* This is the TYPE of device.  */
+  enum offload_target_type type;
+
+  /* Set to true when device is initialized.  */
+  bool is_initialized;
+
+  /* True when offload regions have been registered with this device.  */
+  bool offload_regions_registered;
+
+  /* Function handlers.  */
+  const char *(*get_name_func) (void);
+  unsigned int (*get_caps_func) (void);
+  int (*get_type_func) (void);
+  int (*get_num_devices_func) (void);
+  void (*register_image_func) (void *, void *);
+  void (*init_device_func) (int);
+  void (*fini_device_func) (int);
+  int (*get_table_func) (int, struct mapping_table **);
+  void *(*alloc_func) (int, size_t);
+  void (*free_func) (int, void *);
+  void *(*dev2host_func) (int, void *, const void *, size_t);
+  void *(*host2dev_func) (int, void *, const void *, size_t);
+  void (*run_func) (int, void *, void *);
+
+  /* OpenACC-specific functions.  */
+  acc_dispatch_t openacc;
+
+  /* Memory-mapping info for this device instance.  */
+  struct gomp_memory_mapping mem_map;
+
+  /* Extra information required for a device instance by a given target.  */
+  void *target_data;
+};
+
+extern void gomp_acc_insert_pointer (size_t, void **, size_t *, void *);
+extern void gomp_acc_remove_pointer (void *, bool, int, int);
+
+extern struct target_mem_desc *gomp_map_vars (struct gomp_device_descr *,
+					      size_t, void **, void **,
+					      size_t *, void *, bool, bool);
+
+extern void gomp_copy_from_async (struct target_mem_desc *);
+
+extern void gomp_unmap_vars (struct target_mem_desc *, bool);
+
+extern void gomp_init_device (struct gomp_device_descr *);
+
+extern void gomp_init_tables (const struct gomp_device_descr *,
+			      struct gomp_memory_mapping *);
+
+extern void gomp_fini_device (struct gomp_device_descr *);
+
+extern void gomp_free_memmap (struct gomp_device_descr *);
+
 /* work.c */
 
 extern void gomp_init_work_share (struct gomp_work_share *, bool, unsigned);
diff --git libgomp/libgomp_g.h libgomp/libgomp_g.h
index 4206d51..07d1666 100644
--- libgomp/libgomp_g.h
+++ libgomp/libgomp_g.h
@@ -234,9 +234,4 @@ extern void GOACC_wait (int, int, ...);
 extern int GOACC_get_num_threads (void);
 extern int GOACC_get_thread_num (void);
 
-/* oacc-mem.c */
-
-extern void gomp_acc_insert_pointer (size_t, void **, size_t *, void *);
-extern void gomp_acc_remove_pointer (void *, bool, int, int);
-
 #endif /* LIBGOMP_G_H */
diff --git libgomp/libgomp_target.h libgomp/libgomp_target.h
index 4d658cc..b6723fe 100644
--- libgomp/libgomp_target.h
+++ libgomp/libgomp_target.h
@@ -25,8 +25,6 @@
 #ifndef LIBGOMP_TARGET_H
 #define LIBGOMP_TARGET_H 1
 
-#include "gomp-constants.h"
-
 /* Type of offload target device.  Keep in sync with include/gomp-constants.h.  */
 enum offload_target_type
 {
@@ -46,174 +44,4 @@ struct mapping_table
   uintptr_t tgt_end;
 };
 
-#include "splay-tree.h"
-
-struct target_mem_desc {
-  /* Reference count.  */
-  uintptr_t refcount;
-  /* All the splay nodes allocated together.  */
-  splay_tree_node array;
-  /* Start of the target region.  */
-  uintptr_t tgt_start;
-  /* End of the targer region.  */
-  uintptr_t tgt_end;
-  /* Handle to free.  */
-  void *to_free;
-  /* Previous target_mem_desc.  */
-  struct target_mem_desc *prev;
-  /* Number of items in following list.  */
-  size_t list_count;
-
-  /* Corresponding target device descriptor.  */
-  struct gomp_device_descr *device_descr;
-
-  /* Memory mapping info for the thread that created this descriptor.  */
-  struct gomp_memory_mapping *mem_map;
-
-  /* List of splay keys to remove (or decrease refcount)
-     at the end of region.  */
-  splay_tree_key list[];
-};
-
-#define TARGET_CAP_SHARED_MEM	1
-#define TARGET_CAP_NATIVE_EXEC	2
-#define TARGET_CAP_OPENMP_400	4
-#define TARGET_CAP_OPENACC_200	8
-
-/* Information about mapped memory regions (per device/context).  */
-
-struct gomp_memory_mapping
-{
-  /* Splay tree containing information about mapped memory regions.  */
-  struct splay_tree_s splay_tree;
-
-  /* Mutex for operating with the splay tree and other shared structures.  */
-  gomp_mutex_t lock;
-
-  /* True when tables have been added to this memory map.  */
-  bool is_initialized;
-};
-
-typedef struct acc_dispatch_t
-{
-  /* This is a linked list of data mapped using the
-     acc_map_data/acc_unmap_data or "acc enter data"/"acc exit data" pragmas
-     (TODO).  Unlike mapped_data in the goacc_thread struct, unmapping can
-     happen out-of-order with respect to mapping.  */
-  struct target_mem_desc *data_environ;
-
-  /* Open or close a device instance.  */
-  void *(*open_device_func) (int n);
-  int (*close_device_func) (void *h);
-
-  /* Set or get the device number.  */
-  int (*get_device_num_func) (void);
-  void (*set_device_num_func) (int);
-
-  /* Execute.  */
-  void (*exec_func) (void (*) (void *), size_t, void **, void **, size_t *,
-		     unsigned short *, int, int, int, int, void *);
-
-  /* Async cleanup callback registration.  */
-  void (*register_async_cleanup_func) (void *);
-
-  /* Asynchronous routines.  */
-  int (*async_test_func) (int);
-  int (*async_test_all_func) (void);
-  void (*async_wait_func) (int);
-  void (*async_wait_async_func) (int, int);
-  void (*async_wait_all_func) (void);
-  void (*async_wait_all_async_func) (int);
-  void (*async_set_async_func) (int);
-
-  /* Create/destroy TLS data.  */
-  void *(*create_thread_data_func) (void *);
-  void (*destroy_thread_data_func) (void *);
-
-  /* NVIDIA target specific routines.  */
-  struct {
-    void *(*get_current_device_func) (void);
-    void *(*get_current_context_func) (void);
-    void *(*get_stream_func) (int);
-    int (*set_stream_func) (int, void *);
-  } cuda;
-} acc_dispatch_t;
-
-/* This structure describes accelerator device.
-   It contains name of the corresponding libgomp plugin, function handlers for
-   interaction with the device, ID-number of the device, and information about
-   mapped memory.  */
-struct gomp_device_descr
-{
-  /* The name of the device.  */
-  const char *name;
-
-  /* Capabilities of device (supports OpenACC, OpenMP).  */
-  unsigned int capabilities;
-
-  /* This is the ID number of device.  It could be specified in DEVICE-clause of
-     TARGET construct.  */
-  int id;
-
-  /* This is the ID number of device among devices of the same type.  */
-  int target_id;
-
-  /* This is the TYPE of device.  */
-  enum offload_target_type type;
-
-  /* Set to true when device is initialized.  */
-  bool is_initialized;
-
-  /* True when offload regions have been registered with this device.  */
-  bool offload_regions_registered;
-
-  /* Function handlers.  */
-  const char *(*get_name_func) (void);
-  unsigned int (*get_caps_func) (void);
-  int (*get_type_func) (void);
-  int (*get_num_devices_func) (void);
-  void (*register_image_func) (void *, void *);
-  void (*init_device_func) (int);
-  void (*fini_device_func) (int);
-  int (*get_table_func) (int, struct mapping_table **);
-  void *(*alloc_func) (int, size_t);
-  void (*free_func) (int, void *);
-  void *(*dev2host_func) (int, void *, const void *, size_t);
-  void *(*host2dev_func) (int, void *, const void *, size_t);
-  void (*run_func) (int, void *, void *);
-
-  /* OpenACC-specific functions.  */
-  acc_dispatch_t openacc;
-
-  /* Memory-mapping info for this device instance.  */
-  struct gomp_memory_mapping mem_map;
-
-  /* Extra information required for a device instance by a given target.  */
-  void *target_data;
-};
-
-extern struct target_mem_desc *
-gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum,
-	       void **hostaddrs, void **devaddrs, size_t *sizes, void *kinds,
-	       bool is_openacc, bool is_target);
-
-extern void
-gomp_copy_from_async (struct target_mem_desc *tgt);
-
-extern void
-gomp_unmap_vars (struct target_mem_desc *tgt, bool);
-
-extern attribute_hidden void
-gomp_init_device (struct gomp_device_descr *devicep);
-
-extern attribute_hidden void
-gomp_init_tables (const struct gomp_device_descr *devicep,
-		  struct gomp_memory_mapping *mm);
-
-extern attribute_hidden void
-gomp_fini_device (struct gomp_device_descr *devicep);
-
-extern attribute_hidden void
-gomp_free_memmap (struct gomp_device_descr *devicep);
-
 #endif /* LIBGOMP_TARGET_H */
diff --git libgomp/splay-tree.h libgomp/splay-tree.h
index 2afbbc2..ffe5822 100644
--- libgomp/splay-tree.h
+++ libgomp/splay-tree.h
@@ -81,8 +81,8 @@ struct splay_tree_s {
   splay_tree_node root;
 };
 
-attribute_hidden splay_tree_key splay_tree_lookup (splay_tree, splay_tree_key);
-attribute_hidden void splay_tree_insert (splay_tree, splay_tree_node);
-attribute_hidden void splay_tree_remove (splay_tree, splay_tree_key);
+extern splay_tree_key splay_tree_lookup (splay_tree, splay_tree_key);
+extern void splay_tree_insert (splay_tree, splay_tree_node);
+extern void splay_tree_remove (splay_tree, splay_tree_key);
 
 #endif /* _SPLAY_TREE_H */
