Wednesday Jun 25, 2014

Helping Your Compiler Handle the Size of Your Constants

by Darryl Gove

When I use a constant in the following code, I get a warning:

On the other hand if I wrote:

Then then compiler will quite happily handle the constant.

The problem with the first bit of code is that it treats the value as a signed integer, and a signed integer can only hold 31 bits of precision plus a sign bit.

So how does the compiler decide how to represent a constant? The answer is interesting.

The compiler will attempt to fit a constant into the smallest value that it can. So it will try to fit the value into these types, in order: into an int, a long int, and then a long long int.

In the above code sample, the compiler will find that 1 and 31 both fit very nicely into signed ints. There's a shift left operation (<<) in the expression that produces a result of the same type as the left operand. So the whole expression (1<<31) has type signed int, which leads to the the warning.

To avoid the warning we can tell the compiler that this is an unsigned value. Either by typecasting the 1 to be unsigned in this manner:

or by declaring it as an unsigned value, like this:

More About Oracle Solaris Studio

Oracle Solaris Studio is a C, C++ and Fortran development tool suite, with compiler optimizations, multithread performance, and analysis tools for application development on Oracle Solaris, Oracle Linux, and Red Hat Enterprise Linux operating systems. Find out more about the Oracle Solaris Studio 12.4 Beta program here.

About the Photograph

Photograph of Zion National Park, Utah taken by Rick Ramsey in May 2014 on The Ride to the Sun Reunion.

- Darryl

Follow Darryl on:
Oracle Blog | Twitter
  Follow OTN Garage on:
Web | Facebook | Twitter | YouTube

Friday Jun 13, 2014

Insights into Swap Space on Oracle Solaris 11

What I enjoy about the articles that Oracle ACE Alexandre Borges writes is the insights he provides. For example:

swaplo indicates the minimum possible swap space size, which represents the memory page size (8 sectors x 512 bytes = 4K). To check it:
root@solaris11-1:~# pagesize
4096
A value of 4K is typically found on Intel machines. However, with Oracle Solaris 11 on SPARC machines, the page size can vary from 16K to 2 GB (this upper limit also applies for Intel processors). The upper limit of swap space is mainly used as the page size for the System Global Area (SGA)—a dedicated shared-memory area for an instance of Oracle Database 11g. Additionally, it is worth noting that 2 GB pages are supported with Oracle Solaris 10 8/11 or later Oracle Solaris releases and Oracle's SPARC T4 processor, but this page size isn't enabled by default. If it's suitable for some applications, we have to enable it by inserting set max_uheap_lpsize=0x80000000 in the /etc/system file and then rebooting the system.

Alexandre not only loves working with Oracle Solaris, he takes the trouble to explain its nuances. He's written a series of articles on his experience with Oracle Solaris. This is the second one:

Tech Article: Playing with Swap Monitoring and Increasing Swap Space Using ZFS Volumes in Oracle Solaris 11

by Alexandre Borges

Alexandre walks through several commands and the insight they provide into a system's swap space, and explains how to use them to increase or decrease it.

Stay tuned for more articles from Alexandre in the coming weeks.

About the Photograph

Photograph of 01 Ducati 748 vertical cylinder piston and rings taken by Rick Ramsey in Colorado

- Rick

Follow Alexandre on:
His Blog | Twitter
  Follow OTN on:
Web | Facebook | Twitter | YouTube

Wednesday Jun 11, 2014

Troubleshooting Your Network with Oracle Linux

Are you afraid of network problems? I was. Whenever somebody said "it's probably the network," I went to lunch. And hoped that it was fixed by the time I got back. Turns out it wasn't that hard to do a little basic troubleshooting

Tech Article: Troubleshooting Your Network with Oracle Linux

by Robert Chase

You're no doubt already familiar with ping. Even I knew how to use ping. Turns out there's another command that can show you not just whether a system can respond over the network, but the path the packets to that system take. Our blogging platform won't allow me to write the name down, but I can tell you that if you replace the x in this word with an e, you'll have the right command:

tracxroute

Once you get used to those, you can venture into the realms of mtr, nmap, and netcap.

Robert Chase explains how each one can help you troubleshoot the network, and provides examples for how to use them. Robert is not only a solid writer, he is also a brilliant motorcyclist and rides an MV Augusta F4 750.

About the Photograph

Photo of flowers in San Simeon, California, taken by Rick Ramsey on a ride home from the Sun Reunion in May 2014.

- Rick
Follow me on:
Personal Blog | Personal Twitter
  Follow OTN Garage on:
Web | Facebook | Twitter | YouTube
About

Contributors:
Rick Ramsey
Kemer Thomson
and members of the OTN community

Search

Archives
« June 2014 »
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
12
14
15
16
17
18
19
20
21
22
23
24
26
27
28
29
30
     
       
Today
Blogs We Like