Skip to content

Commit

Permalink
Ensure pack 1
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmorato committed Jun 27, 2024
1 parent d5321da commit d015176
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
17 changes: 7 additions & 10 deletions Native/OpenDDSWrapper/TimeValueWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ along with OpenDDSharp. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************/
#pragma once

#include "Utils.h"
#include "dds/DCPS/TimeDuration.h"
#include <dds/DCPS/TimeDuration.h>

EXTERN_STRUCT_EXPORT TimeValueWrapper {
CORBA::LongLong sec;
CORBA::Long microsec;
#pragma pack(push, 1)
EXTERN_STRUCT_EXPORT
TimeValueWrapper {
::CORBA::LongLong sec;
::CORBA::Long microsec;

public:

TimeValueWrapper() {
sec = 0;
microsec = 0;
}

TimeValueWrapper(const ::OpenDDS::DCPS::TimeDuration td) {
sec = td.value().sec();
microsec = td.value().usec();
Expand All @@ -42,3 +38,4 @@ EXTERN_STRUCT_EXPORT TimeValueWrapper {
return ::OpenDDS::DCPS::TimeDuration(sec, microsec);
}
};
#pragma pack(pop)
4 changes: 2 additions & 2 deletions Native/OpenDDSWrapper/TransportConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void TransportConfig_SetSwapBytes(::OpenDDS::DCPS::TransportConfig *cfg, CORBA::
cfg->swap_bytes_ = value;
}

TimeValueWrapper TransportConfig_GetPassiveConnectDuration(::OpenDDS::DCPS::TransportConfig *cfg) {
return cfg->passive_connect_duration_.get();
CORBA::UInt32 TransportConfig_GetPassiveConnectDuration(::OpenDDS::DCPS::TransportConfig *cfg) {
return cfg->passive_connect_duration_.get().value().msec();
}

void TransportConfig_SetPassiveConnectDuration(::OpenDDS::DCPS::TransportConfig *cfg, CORBA::UInt32 value) {
Expand Down
2 changes: 1 addition & 1 deletion Native/OpenDDSWrapper/TransportConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ EXTERN_METHOD_EXPORT
void TransportConfig_SetSwapBytes(::OpenDDS::DCPS::TransportConfig *cfg, CORBA::Boolean value);

EXTERN_METHOD_EXPORT
TimeValueWrapper TransportConfig_GetPassiveConnectDuration(::OpenDDS::DCPS::TransportConfig *cfg);
CORBA::UInt32 TransportConfig_GetPassiveConnectDuration(::OpenDDS::DCPS::TransportConfig *cfg);

EXTERN_METHOD_EXPORT
void TransportConfig_SetPassiveConnectDuration(::OpenDDS::DCPS::TransportConfig *cfg, CORBA::UInt32 value);
Expand Down
22 changes: 16 additions & 6 deletions Sources/OpenDDSharp/TimeValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,38 @@ You should have received a copy of the GNU Lesser General Public License
**********************************************************************/
using System;
using System.Runtime.InteropServices;
using System.Security.Cryptography;

namespace OpenDDSharp;

/// <summary>
/// Structure for time value representation.
/// </summary>
[StructLayout(LayoutKind.Explicit)]
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TimeValue : IEquatable<TimeValue>
{
[MarshalAs(UnmanagedType.I8)]
private long _seconds;
[MarshalAs(UnmanagedType.I4)]
private int _microSeconds;

#region Properties
/// <summary>
/// Gets or sets the seconds.
/// </summary>
[field: FieldOffset(0)]
public long Seconds { get; set; }
public long Seconds
{
get => _seconds;
set => _seconds = value;
}

/// <summary>
/// Gets or sets the microseconds.
/// </summary>
[field: FieldOffset(8)]
public int MicroSeconds { get; set; }
public int MicroSeconds
{
get => _microSeconds;
set => _microSeconds = value;
}
#endregion

#region IEquatable<TimeValue> Members
Expand Down

0 comments on commit d015176

Please sign in to comment.