I've been reading online and it seems like what people are saying is that gun violence is reducing but, still a greater threat than international terrorism.
Every year the CDC published statistics on homicides and assaults, and includes numbers on deaths related to gun violence. The most recent one is from 2013. It says that there were 11,208 deaths from assault (homicide) by discharge of a firearm. That amounts to about 5% of deaths in that year. Of those killed, 9,445 were male and 5,798 were black males. People from the age of 15 to the age of 34 are most likely to die from this cause than any other age range. Additionally, 21,175 people died to self-inflicted (suicide) gun wounds. So that roughly amounts to a split for homicide/suicide gun violence.
In comparison, there were 13-15 deaths (numbers vary) attributed to terrorism. This number includes U.S. citizens killed abroad. Numbers are hard to find for deaths related to terrorism because of how terrorism is classified in the homeland versus abroad.
According to the Global Terrorism Database, there were nearly 10,000 terrorist attacks worldwide in 2013. This amounted to 18,000 deaths. There were 60 countries that reported deaths related to terrorism. The country most affected was Iraq, with over 6,000 deaths related to terrorism. Five countries - Iraq, Afghanistan, Pakistan, Nigeria and Syria - accounted for 80% of terrorism-related deaths.
I know that doesn't tell you what it would be for the last 40 years, but it does give you an idea of the disparities. You could compare the numbers every year to get an idea of patterns. My guess would be 2001 would be the only year that terrorism related deaths in the US would even come close to homicide with a firearm in the US. To answer the question in short, just for 2013:
Homicides with a firearm in the US: 11,208
Terrorism-related homicide: 18,000