[GitHub] sjanc commented on a change in pull request #4: [linux] initial port and osal additions.

2018-04-04 Thread GitBox
sjanc commented on a change in pull request #4: [linux] initial port and osal 
additions.
URL: https://github.com/apache/mynewt-nimble/pull/4#discussion_r167164810
 
 

 ##
 File path: porting/linux/os/os_mutex.c
 ##
 @@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include "os/os.h"
+
+#include 
+
+os_error_t
+os_mutex_init(struct os_mutex *mu)
+{
+if (!mu) {
+return OS_INVALID_PARM;
+}
+
+pthread_mutexattr_t muAttr;
+pthread_mutexattr_settype(, PTHREAD_MUTEX_RECURSIVE_NP);
+pthread_mutex_init(>lock, );
+
+return OS_OK;
+}
+
+os_error_t
+os_mutex_release(struct os_mutex *mu)
+{
+if (!mu) return OS_INVALID_PARM;
+
+if (pthread_mutex_unlock(>lock)) {
+return OS_BAD_MUTEX;
+}
+
+return OS_OK;
+}
+
+os_error_t
+os_mutex_pend(struct os_mutex *mu, uint32_t timeout)
+{
+if (!mu) return OS_INVALID_PARM;
 
 Review comment:
   coding style


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] sjanc commented on a change in pull request #4: [linux] initial port and osal additions.

2018-04-04 Thread GitBox
sjanc commented on a change in pull request #4: [linux] initial port and osal 
additions.
URL: https://github.com/apache/mynewt-nimble/pull/4#discussion_r179080445
 
 

 ##
 File path: porting/linux/config/sdk_config.h
 ##
 @@ -0,0 +1,698 @@
+
 
 Review comment:
   is this needed anyway for host?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] sjanc commented on a change in pull request #4: [linux] initial port and osal additions.

2018-04-04 Thread GitBox
sjanc commented on a change in pull request #4: [linux] initial port and osal 
additions.
URL: https://github.com/apache/mynewt-nimble/pull/4#discussion_r167164892
 
 

 ##
 File path: porting/linux/os/os_mutex.c
 ##
 @@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include "os/os.h"
+
+#include 
+
+os_error_t
+os_mutex_init(struct os_mutex *mu)
+{
+if (!mu) {
+return OS_INVALID_PARM;
+}
+
+pthread_mutexattr_t muAttr;
+pthread_mutexattr_settype(, PTHREAD_MUTEX_RECURSIVE_NP);
+pthread_mutex_init(>lock, );
+
+return OS_OK;
+}
+
+os_error_t
+os_mutex_release(struct os_mutex *mu)
+{
+if (!mu) return OS_INVALID_PARM;
+
+if (pthread_mutex_unlock(>lock)) {
+return OS_BAD_MUTEX;
+}
+
+return OS_OK;
+}
+
+os_error_t
+os_mutex_pend(struct os_mutex *mu, uint32_t timeout)
+{
+if (!mu) return OS_INVALID_PARM;
+
+assert(>lock);
+
+struct timespec wait;
 
 Review comment:
   variables should be defined at beginning of function


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] sjanc commented on a change in pull request #4: [linux] initial port and osal additions.

2018-04-04 Thread GitBox
sjanc commented on a change in pull request #4: [linux] initial port and osal 
additions.
URL: https://github.com/apache/mynewt-nimble/pull/4#discussion_r167164786
 
 

 ##
 File path: porting/linux/os/os_mutex.c
 ##
 @@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include "os/os.h"
+
+#include 
+
+os_error_t
+os_mutex_init(struct os_mutex *mu)
+{
+if (!mu) {
+return OS_INVALID_PARM;
+}
+
+pthread_mutexattr_t muAttr;
+pthread_mutexattr_settype(, PTHREAD_MUTEX_RECURSIVE_NP);
+pthread_mutex_init(>lock, );
+
+return OS_OK;
+}
+
+os_error_t
+os_mutex_release(struct os_mutex *mu)
+{
+if (!mu) return OS_INVALID_PARM;
 
 Review comment:
   coding style


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] sjanc commented on a change in pull request #4: [linux] initial port and osal additions.

2018-04-04 Thread GitBox
sjanc commented on a change in pull request #4: [linux] initial port and osal 
additions.
URL: https://github.com/apache/mynewt-nimble/pull/4#discussion_r167163624
 
 

 ##
 File path: porting/linux/Makefile.common
 ##
 @@ -0,0 +1,177 @@
+# Copyright (c) 2016 Nordic Semiconductor. All Rights Reserved.
+#
+# The information contained herein is property of Nordic Semiconductor ASA.
+# Terms and conditions of usage are described in detail in NORDIC
+# SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+#
+# Licensees are granted free, non-transferable use of the information. NO
+# WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+# the file.
 
 Review comment:
   Needs to be checked if this license is apache approved.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] sjanc commented on a change in pull request #4: [linux] initial port and osal additions.

2018-04-04 Thread GitBox
sjanc commented on a change in pull request #4: [linux] initial port and osal 
additions.
URL: https://github.com/apache/mynewt-nimble/pull/4#discussion_r167164236
 
 

 ##
 File path: porting/linux/os/os_atomic.c
 ##
 @@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+
+pthread_mutex_t s_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+pthread_cond_t s_cond = PTHREAD_COND_INITIALIZER;
+
+void os_atomic_begin()
+{
+pthread_mutex_lock(_mutex);
+}
+
+void os_atomic_end()
+{
+pthread_mutex_unlock(_mutex);
+pthread_cond_signal(_cond);
 
 Review comment:
   why this conditional is needed? there seems to be no pthread_cond_wait() 
called anywhere for s_cond


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] sjanc commented on a change in pull request #4: [linux] initial port and osal additions.

2018-04-04 Thread GitBox
sjanc commented on a change in pull request #4: [linux] initial port and osal 
additions.
URL: https://github.com/apache/mynewt-nimble/pull/4#discussion_r167165091
 
 

 ##
 File path: porting/linux/os/os_sem.h
 ##
 @@ -0,0 +1,26 @@
+#ifndef _OS_SEM_H_
 
 Review comment:
   license


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] sjanc commented on a change in pull request #4: [linux] initial port and osal additions.

2018-04-04 Thread GitBox
sjanc commented on a change in pull request #4: [linux] initial port and osal 
additions.
URL: https://github.com/apache/mynewt-nimble/pull/4#discussion_r179079914
 
 

 ##
 File path: porting/linux/os/os_atomic.c
 ##
 @@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+
+pthread_mutex_t s_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+pthread_cond_t s_cond = PTHREAD_COND_INITIALIZER;
 
 Review comment:
   should be static?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] sjanc commented on a change in pull request #4: [linux] initial port and osal additions.

2018-04-04 Thread GitBox
sjanc commented on a change in pull request #4: [linux] initial port and osal 
additions.
URL: https://github.com/apache/mynewt-nimble/pull/4#discussion_r167163692
 
 

 ##
 File path: porting/linux/config/sdk_config.h
 ##
 @@ -0,0 +1,698 @@
+
 
 Review comment:
   miising license


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] sjanc commented on a change in pull request #4: [linux] initial port and osal additions.

2018-04-04 Thread GitBox
sjanc commented on a change in pull request #4: [linux] initial port and osal 
additions.
URL: https://github.com/apache/mynewt-nimble/pull/4#discussion_r167165034
 
 

 ##
 File path: porting/linux/os/os_sem.c
 ##
 @@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include "os/os.h"
+
+#include 
+#include 
+#include 
+
+
+os_error_t
+os_sem_init(struct os_sem *sem, uint16_t tokens)
+{
+if (!sem)
 
 Review comment:
   style


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services