You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mnemonic.apache.org by xj...@apache.org on 2022/07/22 04:01:56 UTC

[mnemonic] branch master updated: MNEMONIC-751: Add common.h to memkind service

This is an automated email from the ASF dual-hosted git repository.

xjiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mnemonic.git


The following commit(s) were added to refs/heads/master by this push:
     new ca3ac8a  MNEMONIC-751: Add common.h to memkind service
ca3ac8a is described below

commit ca3ac8a1e5a01aa8aaf87019fdaf09db3ecf0549
Author: Yanhui Zhao <yz...@apache.org>
AuthorDate: Mon Jul 18 21:28:30 2022 -0700

    MNEMONIC-751: Add common.h to memkind service
---
 .../src/main/native/common.h                       | 68 ++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/mnemonic-memory-services/mnemonic-memkind-pmem-service/src/main/native/common.h b/mnemonic-memory-services/mnemonic-memkind-pmem-service/src/main/native/common.h
new file mode 100644
index 0000000..44edbd1
--- /dev/null
+++ b/mnemonic-memory-services/mnemonic-memkind-pmem-service/src/main/native/common.h
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 _COMMON_H
+#define _COMMON_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <stdint.h>
+#include <assert.h>
+#include <pthread.h>
+#include <jni.h>
+#include <memkind.h>
+
+void throw(JNIEnv* env, const char* msg);
+
+void* addr_from_java(jlong addr);
+
+jlong addr_to_java(void* p);
+
+typedef struct {
+  //size_t size;
+  jlong size;
+} PMBHeader;
+
+#define PMBHSZ (sizeof(PMBHeader))
+
+typedef struct {
+  memkind_t *kind;
+  size_t capacity;
+  pthread_mutex_t mutex;
+} VMPool;
+
+void *vrealloc(VMPool *pool, void *p, size_t size, int initzero);
+
+void vfree(VMPool *pool, void *p);
+
+size_t vsize(VMPool *pool, void *p);
+
+#ifdef __cplusplus
+}
+#endif
+#endif